Java 类javax.swing.plaf.basic.BasicTextFieldUI 实例源码

项目:gcs    文件:PageField.java   
/**
 * Creates a new text input field.
 *
 * @param sheet The sheet to listen to.
 * @param consumedType The field to listen to.
 * @param alignment The alignment of the field.
 * @param editable Whether or not the user can edit this field.
 * @param tooltip The tooltip to set.
 */
public PageField(CharacterSheet sheet, String consumedType, int alignment, boolean editable, String tooltip) {
    super(getFormatterFactoryForType(consumedType), sheet.getCharacter().getValueForID(consumedType));
    if (Platform.isLinux()) {
        // I override the UI here since the GTK UI on Linux has no way to turn off the border
        // around text fields.
        setUI(new BasicTextFieldUI());
    }
    mSheet = sheet;
    mConsumedType = consumedType;
    setFont(sheet.getScale().scale(UIManager.getFont(GCSFonts.KEY_FIELD)));
    setBorder(null);
    setOpaque(false);
    // Just setting opaque to false isn't enough for some reason, so I'm also setting the
    // background color to a 100% transparent value.
    setBackground(new Color(255, 255, 255, 0));
    setHorizontalAlignment(alignment);
    setEditable(editable);
    setEnabled(editable);
    setForeground(editable ? Color.BLACK : Color.GRAY);
    if (tooltip != null) {
        setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
        if (tooltip.indexOf("{") != -1) { //$NON-NLS-1$
            mCustomToolTip = tooltip;
        }
    }
    mSheet.getCharacter().addTarget(this, mConsumedType);
    addPropertyChangeListener("value", this); //$NON-NLS-1$
    addActionListener(this);
    setFocusLostBehavior(COMMIT_OR_REVERT);

    // Reset the selection colors back to what is standard for text fields.
    // This is necessary, since (at least on the Mac) JFormattedTextField
    // has the wrong values by default.
    setCaretColor(UIManager.getColor("TextField.caretForeground")); //$NON-NLS-1$
    setSelectionColor(UIManager.getColor("TextField.selectionBackground")); //$NON-NLS-1$
    setSelectedTextColor(UIManager.getColor("TextField.selectionForeground")); //$NON-NLS-1$
    setDisabledTextColor(UIManager.getColor("TextField.inactiveForeground")); //$NON-NLS-1$
}
项目:GdxStudio    文件:GoToMemberWindow.java   
/**
 * Creates the text field allowing the user to enter filter text.
 *
 * @return The text field.
 */
private JTextField createTextField() {
    JTextField field = new JTextField(30);
    field.setUI(new BasicTextFieldUI());
    field.setBorder(new TextFieldBorder());
    field.addActionListener(listener);
    field.addKeyListener(listener);
    field.getDocument().addDocumentListener(listener);
    return field;
}
项目:RSTALanguageSupport    文件:GoToMemberWindow.java   
/**
 * Creates the text field allowing the user to enter filter text.
 *
 * @return The text field.
 */
private JTextField createTextField() {
    JTextField field = new JTextField(30);
    field.setUI(new BasicTextFieldUI());
    field.setBorder(new TextFieldBorder());
    field.addActionListener(listener);
    field.addKeyListener(listener);
    field.getDocument().addDocumentListener(listener);
    return field;
}
项目:samebug-idea-plugin    文件:InputField.java   
@Override
public void updateUI() {
    setUI(new BasicTextFieldUI());
    if (myColors != null) updateColors();
}
项目:swingx    文件:PromptSupportTest.java   
private void promptSupportMustStayInstalled() {
    assertEquals(BuddyTextFieldUI.class, txt.getUI().getClass());
    txt.setUI(new BasicTextFieldUI());
    assertEquals(BuddyTextFieldUI.class, txt.getUI().getClass());
}
项目:swingx    文件:TextUIWrapperTest.java   
private void mustBeInstalled() {
    assertEquals(BuddyTextFieldUI.class, txt.getUI().getClass());
    txt.setUI(new BasicTextFieldUI());
    assertEquals(BasicTextFieldUI.class, txt.getUI().getClass());
}
项目:swingx    文件:TextUIWrapperTest.java   
private void mustStayInstalled() {
    assertEquals(BuddyTextFieldUI.class, txt.getUI().getClass());
    txt.setUI(new BasicTextFieldUI());
    assertEquals(BuddyTextFieldUI.class, txt.getUI().getClass());
}