FileDocCategorySizeDatePackage
BasicTextFieldUI.javaAPI DocJava SE 6 API12964Tue Jun 10 00:26:48 BST 2008javax.swing.plaf.basic

BasicTextFieldUI

public class BasicTextFieldUI extends BasicTextUI
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 {@link java.beans.XMLEncoder}.

author
Timothy Prinzing
version
1.98 04/20/06

Fields Summary
Constructors Summary
public BasicTextFieldUI()
Creates a new BasicTextFieldUI.

	super();
    
Methods Summary
public javax.swing.text.Viewcreate(javax.swing.text.Element elem)
Creates a view (FieldView) based on an element.

param
elem the element
return
the view

	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);
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent c)
Creates a UI for a JTextField.

param
c the text field
return
the UI

        return new BasicTextFieldUI();
    
public intgetBaseline(javax.swing.JComponent c, int width, int height)
Returns the baseline.

throws
NullPointerException {@inheritDoc}
throws
IllegalArgumentException {@inheritDoc}
see
javax.swing.JComponent#getBaseline(int, int)
since
1.6

        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 java.awt.Component$BaselineResizeBehaviorgetBaselineResizeBehavior(javax.swing.JComponent c)
Returns an enum indicating how the baseline of the component changes as the size changes.

throws
NullPointerException {@inheritDoc}
see
javax.swing.JComponent#getBaseline(int, int)
since
1.6

        super.getBaselineResizeBehavior(c);
        return Component.BaselineResizeBehavior.CENTER_OFFSET;
    
protected java.lang.StringgetPropertyPrefix()
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
the name ("TextField")

	return "TextField";