本文整理汇总了Java中javax.swing.plaf.basic.BasicTextFieldUI类的典型用法代码示例。如果您正苦于以下问题:Java BasicTextFieldUI类的具体用法?Java BasicTextFieldUI怎么用?Java BasicTextFieldUI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicTextFieldUI类属于javax.swing.plaf.basic包,在下文中一共展示了BasicTextFieldUI类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PageField
import javax.swing.plaf.basic.BasicTextFieldUI; //导入依赖的package包/类
/**
* 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$
}
示例2: createTextField
import javax.swing.plaf.basic.BasicTextFieldUI; //导入依赖的package包/类
/**
* 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;
}
示例3: updateUI
import javax.swing.plaf.basic.BasicTextFieldUI; //导入依赖的package包/类
@Override
public void updateUI() {
setUI(new BasicTextFieldUI());
if (myColors != null) updateColors();
}
示例4: promptSupportMustStayInstalled
import javax.swing.plaf.basic.BasicTextFieldUI; //导入依赖的package包/类
private void promptSupportMustStayInstalled() {
assertEquals(BuddyTextFieldUI.class, txt.getUI().getClass());
txt.setUI(new BasicTextFieldUI());
assertEquals(BuddyTextFieldUI.class, txt.getUI().getClass());
}
示例5: mustBeInstalled
import javax.swing.plaf.basic.BasicTextFieldUI; //导入依赖的package包/类
private void mustBeInstalled() {
assertEquals(BuddyTextFieldUI.class, txt.getUI().getClass());
txt.setUI(new BasicTextFieldUI());
assertEquals(BasicTextFieldUI.class, txt.getUI().getClass());
}
示例6: mustStayInstalled
import javax.swing.plaf.basic.BasicTextFieldUI; //导入依赖的package包/类
private void mustStayInstalled() {
assertEquals(BuddyTextFieldUI.class, txt.getUI().getClass());
txt.setUI(new BasicTextFieldUI());
assertEquals(BuddyTextFieldUI.class, txt.getUI().getClass());
}