Java Reference
In-Depth Information
try {
System.out.println("Contents: " + source.getText(0, length));
} catch (BadLocationException badLocationException) {
System.out.println("Contents: Unknown");
}
}
};
nameTextField.getDocument().addDocumentListener(documentListener);
cityTextField.getDocument().addDocumentListener(documentListener);
frame.setSize(250, 100);
frame.setVisible(true);
}
};
EventQueue.invokeLater(runner);
}
}
Customizing a JTextField Look and Feel
Each installable Swing look and feel provides a different JTextField appearance and set of
default UIResource values. The available set of 25 UIResource -related properties for a JTextField is
shown in Table 15-5.
Table 15-5. JTextField UIResource Elements
Property String
Object Type
text
Color
textHighlight
Color
textHighlightText
Color
textInactiveText
Color
TextField.actionMap
ActionMap
TextField.background
Color
TextField.border
Border
TextField.caretAspectRatio
Number
TextField.caretBlinkRate
Integer
TextField.caretForeground
Color
TextField.darkShadow
Color
TextField.disabledBackground
Color
TextField.focusInputMap
InputMap
TextField.font
Font
Search WWH ::




Custom Search