javax.swing.plaf.basic
public class: BasicTextFieldUI [javadoc |
source]
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.TextUI
javax.swing.plaf.basic.BasicTextUI
javax.swing.plaf.basic.BasicTextFieldUI
All Implemented Interfaces:
ViewFactory
Direct Known Subclasses:
MetalTextFieldUI, BasicFormattedTextFieldUI, SynthFormattedTextFieldUI, SynthPasswordFieldUI, SynthTextFieldUI, BasicPasswordFieldUI
Basis of a look and feel for a JTextField.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see java.beans.XMLEncoder .
- author:
Timothy - Prinzing
| Nested Class Summary: |
|---|
| static class | BasicTextFieldUI.I18nFieldView | A field view that support bidirectional text via the
support provided by ParagraphView. |
| Methods from javax.swing.plaf.basic.BasicTextUI: |
|---|
|
create, create, createActionMap, createCaret, createHighlighter, createKeymap, damageRange, damageRange, getActionMap, getComponent, getEditorKit, getInputMap, getKeymapName, getMaximumSize, getMinimumSize, getNextVisualPositionFrom, getPreferredSize, getPropertyPrefix, getRootView, getToolTipText, getTransferHandler, getVisibleEditorRect, installDefaults, installKeyboardActions, installListeners, installUI, modelChanged, modelToView, modelToView, paint, paintBackground, paintSafely, propertyChange, setView, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI, update, updateFocusAcceleratorBinding, updateFocusTraversalKeys, viewToModel, viewToModel |
| Methods from javax.swing.plaf.ComponentUI: |
|---|
|
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, installUI, paint, uninstallUI, update |
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from javax.swing.plaf.basic.BasicTextFieldUI Detail: |
public View create(Element elem) {
Document doc = elem.getDocument();
Object i18nFlag = doc.getProperty("i18n"/*AbstractDocument.I18NProperty*/);
if (Boolean.TRUE.equals(i18nFlag)) {
// 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);
}
Creates a view (FieldView) based on an element. |
public static ComponentUI createUI(JComponent c) {
return new BasicTextFieldUI();
}
Creates a UI for a JTextField. |
public int getBaseline(JComponent c,
int width,
int height) {
super.getBaseline(c, width, height);
View rootView = getRootView((JTextComponent)c);
if (rootView.getViewCount() > 0) {
Insets insets = c.getInsets();
height = height - insets.top - insets.bottom;
if (height > 0) {
int baseline = insets.top;
View fieldView = rootView.getView(0);
int vspan = (int)fieldView.getPreferredSpan(View.Y_AXIS);
if (height != vspan) {
int slop = height - vspan;
baseline += slop / 2;
}
if (fieldView instanceof I18nFieldView) {
int fieldBaseline = BasicHTML.getBaseline(
fieldView, width - insets.left - insets.right,
height);
if (fieldBaseline < 0) {
return -1;
}
baseline += fieldBaseline;
}
else {
FontMetrics fm = c.getFontMetrics(c.getFont());
baseline += fm.getAscent();
}
return baseline;
}
}
return -1;
}
|
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) {
super.getBaselineResizeBehavior(c);
return Component.BaselineResizeBehavior.CENTER_OFFSET;
}
Returns an enum indicating how the baseline of the component
changes as the size changes. |
protected String getPropertyPrefix() {
return "TextField";
}
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. |