Methods Summary |
---|
public javax.swing.text.View | create(javax.swing.text.Element elem)Creates a view (FieldView) based on an element.
Document doc = elem.getDocument();
Object i18nFlag = doc.getProperty("i18n"/*AbstractDocument.I18NProperty*/);
if ((i18nFlag != null) && i18nFlag.equals(Boolean.TRUE)) {
// To support bidirectional text, we build a more heavyweight
// representation of the field.
String kind = elem.getName();
if (kind != null) {
if (kind.equals(AbstractDocument.ContentElementName)) {
return new GlyphView(elem);
} else if (kind.equals(AbstractDocument.ParagraphElementName)) {
return new I18nFieldView(elem);
}
}
// this shouldn't happen, should probably throw in this case.
}
return new FieldView(elem);
|
public static javax.swing.plaf.ComponentUI | createUI(javax.swing.JComponent c)Creates a UI for a JTextField.
return new BasicTextFieldUI();
|
protected java.lang.String | getPropertyPrefix()Fetches the name used as a key to lookup properties through the
UIManager. This is used as a prefix to all the standard
text properties.
return "TextField";
|
public void | installUI(javax.swing.JComponent c)
super.installUI(c);
updateBackground((JTextComponent)c);
|
protected void | propertyChange(java.beans.PropertyChangeEvent evt)This method gets called when a bound property is changed
on the associated JTextComponent. This is a hook
which UI implementations may change to reflect how the
UI displays bound properties of JTextComponent subclasses.
if (evt.getPropertyName().equals("editable") ||
evt.getPropertyName().equals("enabled")) {
updateBackground((JTextComponent)evt.getSource());
}
|
private void | updateBackground(javax.swing.text.JTextComponent c)
Color background = c.getBackground();
if (background instanceof UIResource) {
Color newColor = null;
String prefix = getPropertyPrefix();
if (!c.isEnabled()) {
newColor = DefaultLookup.getColor(c, this,
prefix + ".disabledBackground",
null);
}
if (newColor == null && !c.isEditable()) {
newColor = DefaultLookup.getColor(c, this,
prefix + ".inactiveBackground",
null);
}
if (newColor == null) {
newColor = DefaultLookup.getColor(c, this,
prefix + ".background",
null);
}
if (newColor != null && newColor != background) {
c.setBackground(newColor);
}
}
|