本文整理匯總了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());
}