javax.swing.text.JTextComponent#setEditable ( )源码实例Demo

下面列出了javax.swing.text.JTextComponent#setEditable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: java-swing-tips   文件: MainPanel.java
private static Box makeLeftIcon(JTextComponent label, ImageIcon icon) {
  label.setForeground(UIManager.getColor("Label.foreground"));
  // label.setBackground(UIManager.getColor("Label.background"));
  label.setOpaque(false);
  label.setEditable(false);
  label.setFocusable(false);
  label.setMaximumSize(label.getPreferredSize());
  label.setMinimumSize(label.getPreferredSize());

  JLabel l = new JLabel(icon);
  l.setCursor(Cursor.getDefaultCursor());
  Box box = Box.createHorizontalBox();
  box.add(l);
  box.add(Box.createHorizontalStrut(2));
  box.add(label);
  box.add(Box.createHorizontalGlue());
  return box;
}
 
源代码2 项目: orbit-image-analysis   文件: LookAndFeelTweaks.java
public static void makeMultilineLabel(JTextComponent area) {
  area.setFont(UIManager.getFont("Label.font"));
  area.setEditable(false);
  area.setOpaque(false);    
  if (area instanceof JTextArea) {
    ((JTextArea)area).setWrapStyleWord(true);
    ((JTextArea)area).setLineWrap(true);
  }
}
 
源代码3 项目: cuba   文件: DesktopPickerField.java
@Override
protected void setEditableToComponent(boolean editable) {
    for (Action action : actionsOrder) {
        if (action instanceof StandardAction) {
            ((StandardAction) action).setEditable(editable);
        }
    }
    if (!editable && impl.getEditor() instanceof JTextComponent) {
        JTextComponent editor = (JTextComponent) impl.getEditor();
        editor.setEditable(false);
    }
    updateMissingValueState();
}
 
源代码4 项目: ET_Redux   文件: DialogEditor.java
/**
 *
 * @param textComp
 * @param editable
 */
public UnDoAbleDocument(JTextComponent textComp, boolean editable) {
    this(textComp);
    textComp.setEditable(editable);
    if (editable) {
        textComp.setBackground(ReduxConstants.myEditingWhiteColor);
    } else {
        textComp.setBackground(ReduxConstants.myNotEditingGreyColor);
    }

    textComp.addFocusListener(new SelectTextFocusListener());
}
 
源代码5 项目: bigtable-sql   文件: BaseSourcePanel.java
/**
   * Create the user interface.
   * The created {@link JTextComponent} depends on the {@link ISQLEntryPanelFactory}.
   * This enables support for Syntax-Highlighting, if the syntax plugin is loaded.
   */
  protected void createUserInterface()
  {
  	
  	HashMap<String, Object> props = new HashMap<String, Object>();
  	props.put(IParserEventsProcessorFactory.class.getName(), null);
  	
ISQLEntryPanel sqlPanel = getSession().getApplication().getSQLEntryPanelFactory().createSQLEntryPanel(getSession(), props );
JTextComponent textComponent = sqlPanel.getTextComponent();
textComponent.setEditable(false);
setTextArea(textComponent);
add(getTextArea(), BorderLayout.CENTER);
  }
 
源代码6 项目: CodenameOne   文件: LookAndFeelTweaks.java
public static void makeMultilineLabel(JTextComponent area) {
  area.setFont(UIManager.getFont("Label.font"));
  area.setEditable(false);
  area.setOpaque(false);
  if (area instanceof JTextArea) {
    ((JTextArea) area).setWrapStyleWord(true);
    ((JTextArea) area).setLineWrap(true);
  }
}
 
源代码7 项目: snap-desktop   文件: PromptDialog.java
private static JComponent addComponent(final JPanel content, final GridBagConstraints gbc,
                                       final String label, final String defaultValue, final TYPE type) {
    if (type.equals(TYPE.CHECKBOX)) {
        final JCheckBox checkBox = new JCheckBox(label);
        checkBox.setSelected(!defaultValue.isEmpty());
        content.add(checkBox, gbc);
        return checkBox;
    }
    JTextComponent textComp;
    if (type.equals(TYPE.TEXTAREA)) {
        final JTextArea textArea = new JTextArea(defaultValue);
        textArea.setColumns(50);
        textArea.setRows(7);
        textComp = textArea;
    } else {
        gbc.gridx = 0;
        content.add(new JLabel(label), gbc);
        gbc.weightx = 2;
        gbc.gridx = 1;
        if (type.equals(TYPE.PASSWORD)) {
            textComp = new  JPasswordField(defaultValue);
            ((JPasswordField)textComp).setEchoChar('*');
        } else {
            textComp = new JTextField(defaultValue);
        }
        gbc.weightx = 1;
    }
    textComp.setEditable(true);
    content.add(textComp, gbc);
    gbc.gridx = 0;
    return textComp;
}
 
源代码8 项目: nextreports-designer   文件: LookAndFeelTweaks.java
public static void makeMultilineLabel(JTextComponent area) {
    area.setFont(UIManager.getFont("Label.font"));
    area.setEditable(false);
    area.setOpaque(false);
    if (area instanceof JTextArea) {
        ((JTextArea) area).setWrapStyleWord(true);
        ((JTextArea) area).setLineWrap(true);
    }
}
 
源代码9 项目: netbeans   文件: InPlaceEditLayer.java
void setEditedComponent(Component comp, String text) {
    if (!comp.isShowing() || comp.getParent() == null)
        throw new IllegalArgumentException();

    editedComp = comp;
    editedText = text;
    if (inPlaceField != null) {
        remove(inPlaceField);
        inPlaceField = null;
    }

    if (comp instanceof JLabel || comp instanceof AbstractButton || comp instanceof JTabbedPane) {
        layerEditing = true;
        superContainer = null;
        createInPlaceField();
    }
    else if (comp instanceof JTextField || comp instanceof JTextArea) {
        layerEditing = false;
        superContainer = comp.getParent();

        Container cont = superContainer;
        do {
            if (cont.getParent() instanceof JLayeredPane) {
                superContainer = cont;
                break;
            }
            else cont = cont.getParent();
        }
        while (cont != null);

        editingTextComp = (JTextComponent)editedComp;
        oldText = editingTextComp.getText();
        editingTextComp.setText(editedText);

        // enable focus on component in component layer
        editingTextComp.setFocusable(true);
        if (!editingTextComp.isEnabled()) {
            editingTextComp.setEnabled(true);
            enabled = true;
        }
        if (!editingTextComp.isEditable()) {
            editingTextComp.setEditable(true);
            madeEditable = true;
        }
    }
    else throw new IllegalArgumentException();

    if (editingTextComp != null) {
        FormUtils.setupTextUndoRedo(editingTextComp);
    }

    attachListeners();
}
 
public MessageConsole(JTextComponent textComponent, boolean isAppend) {
    this.textComponent = textComponent;
    this.document = textComponent.getDocument();
    this.isAppend = isAppend;
    textComponent.setEditable(false);
}
 
源代码11 项目: portable-ftp-server   文件: MessageConsole.java
/**
 * Instantiates a new message console.
 *
 * @param textComponent the text component
 */
public MessageConsole(JTextComponent textComponent){
	this.textComponent = textComponent;
	this.document = textComponent.getDocument();
	textComponent.setEditable(false);
}
 
源代码12 项目: eml-to-pdf-converter   文件: MessageConsole.java
public MessageConsole(JTextComponent textComponent, boolean isAppend) {
	this.textComponent = textComponent;
	this.document = textComponent.getDocument();
	this.isAppend = isAppend;
	textComponent.setEditable(false);
}
 
源代码13 项目: yawl   文件: FrameUtil.java
public static void readOnly(JTextComponent c, JComponent parent) {
  c.setEditable(false);
  c.setForeground(parent.getForeground());
  c.setBackground(parent.getBackground());
}
 
源代码14 项目: java-swing-tips   文件: MainPanel.java
private MainPanel() {
  super(new BorderLayout());
  String[] columnNames = {"String", "Integer", "Boolean"};
  Object[][] data = {
    {"aaa", 12, true}, {"zzz", 6, false}, {"bbb", 22, true}, {"nnn", 9, false},
    {"ccc", 32, true}, {"ooo", 8, false}, {"ddd", 42, true}, {"ppp", 9, false},
    {"eee", 52, true}, {"qqq", 8, false}, {"fff", 62, true}, {"rrr", 7, false},
    {"ggg", 51, true}, {"sss", 6, false}, {"hhh", 41, true}, {"ttt", 5, false},
    {"iii", 51, true}, {"uuu", 4, false}, {"jjj", 61, true}, {"vvv", 3, false},
    {"kkk", 72, true}, {"www", 2, false}, {"lll", 82, true}, {"xxx", 1, false},
    {"mmm", 92, true}, {"yyy", 0, false}
  };
  DefaultTableModel model = new DefaultTableModel(data, columnNames) {
    @Override public Class<?> getColumnClass(int column) {
      return getValueAt(0, column).getClass();
    }
  };
  JTable table = new JTable(model);
  table.setAutoCreateRowSorter(true);

  JTextPane textPane = new JTextPane();
  textPane.setEditable(false);
  textPane.setMargin(new Insets(5, 10, 5, 5));

  JTextComponent c = new JTextArea(TEXT);
  c.setEditable(false);

  Document doc = textPane.getDocument();
  try {
    doc.insertString(doc.getLength(), TEXT, null);
    doc.insertString(doc.getLength(), TEXT, null);
    doc.insertString(doc.getLength(), TEXT, null);
    textPane.insertComponent(createChildScrollPane(c));
    doc.insertString(doc.getLength(), "\n", null);
    doc.insertString(doc.getLength(), TEXT, null);
    textPane.insertComponent(createChildScrollPane(table));
    doc.insertString(doc.getLength(), "\n", null);
    doc.insertString(doc.getLength(), TEXT, null);
    textPane.insertComponent(new JScrollPane(new JTree()));
    doc.insertString(doc.getLength(), "\n", null);
    doc.insertString(doc.getLength(), TEXT, null);
  } catch (BadLocationException ex) {
    // should never happen
    RuntimeException wrap = new StringIndexOutOfBoundsException(ex.offsetRequested());
    wrap.initCause(ex);
    throw wrap;
  }
  add(new JLayer<>(new JScrollPane(textPane), new WheelScrollLayerUI()));
  // add(new JScrollPane(textPane));
  setPreferredSize(new Dimension(320, 240));
}