jdk/src/share/classes/javax/swing/JLabel.java

Print this page

        

*** 20,51 **** * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ - package javax.swing; import java.awt.Component; - import java.awt.Font; import java.awt.Image; import java.awt.*; import java.text.*; import java.awt.geom.*; import java.beans.Transient; import java.io.ObjectOutputStream; - import java.io.ObjectInputStream; import java.io.IOException; import javax.swing.plaf.LabelUI; import javax.accessibility.*; import javax.swing.text.*; - import javax.swing.text.html.*; - import javax.swing.plaf.basic.*; - import java.util.*; - /** * A display area for a short text string or an image, * or both. * A label does not react to input events. --- 20,46 ---- * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javax.swing; import java.awt.Component; import java.awt.Image; import java.awt.*; import java.text.*; import java.awt.geom.*; + import java.beans.JavaBean; + import java.beans.BeanProperty; import java.beans.Transient; import java.io.ObjectOutputStream; import java.io.IOException; import javax.swing.plaf.LabelUI; import javax.accessibility.*; import javax.swing.text.*; /** * A display area for a short text string or an image, * or both. * A label does not react to input events.
*** 96,112 **** * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * - * @beaninfo - * attribute: isContainer false - * description: A component that displays a short string and an icon. - * * @author Hans Muller * @since 1.2 */ @SuppressWarnings("serial") public class JLabel extends JComponent implements SwingConstants, Accessible { /** * @see #getUIClassID --- 91,105 ---- * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @author Hans Muller * @since 1.2 */ + @JavaBean(defaultProperty = "UI", description = "A component that displays a short string and an icon.") + @SwingContainer(false) @SuppressWarnings("serial") public class JLabel extends JComponent implements SwingConstants, Accessible { /** * @see #getUIClassID
*** 254,269 **** /** * Sets the L&amp;F object that renders this component. * * @param ui the LabelUI L&amp;F object * @see UIDefaults#getUI - * @beaninfo - * bound: true - * hidden: true - * attribute: visualUpdate true - * description: The UI object that implements the Component's LookAndFeel. */ public void setUI(LabelUI ui) { super.setUI(ui); // disabled icon is generated by LF so it should be unset here if (!disabledIconSet && disabledIcon != null) { setDisabledIcon(null); --- 247,259 ---- /** * Sets the L&amp;F object that renders this component. * * @param ui the LabelUI L&amp;F object * @see UIDefaults#getUI */ + @BeanProperty(hidden = true, visualUpdate = true, description + = "The UI object that implements the Component's LookAndFeel.") public void setUI(LabelUI ui) { super.setUI(ui); // disabled icon is generated by LF so it should be unset here if (!disabledIconSet && disabledIcon != null) { setDisabledIcon(null);
*** 275,285 **** * Resets the UI property to a value from the current look and feel. * * @see JComponent#updateUI */ public void updateUI() { ! setUI((LabelUI)UIManager.getUI(this)); } /** * Returns a string that specifies the name of the l&amp;f class --- 265,275 ---- * Resets the UI property to a value from the current look and feel. * * @see JComponent#updateUI */ public void updateUI() { ! setUI((LabelUI) UIManager.getUI(this)); } /** * Returns a string that specifies the name of the l&amp;f class
*** 288,297 **** --- 278,288 ---- * @return String "LabelUI" * * @see JComponent#getUIClassID * @see UIDefaults#getUI */ + @BeanProperty(bound = false) public String getUIClassID() { return uiClassID; }
*** 316,331 **** * * @param text the single line of text this component will display * @see #setVerticalTextPosition * @see #setHorizontalTextPosition * @see #setIcon - * @beaninfo - * preferred: true - * bound: true - * attribute: visualUpdate true - * description: Defines the single line of text this component will display. */ public void setText(String text) { String oldAccessibleName = null; if (accessibleContext != null) { oldAccessibleName = accessibleContext.getAccessibleName(); --- 307,319 ---- * * @param text the single line of text this component will display * @see #setVerticalTextPosition * @see #setHorizontalTextPosition * @see #setIcon */ + @BeanProperty(preferred = true, visualUpdate = true, description + = "Defines the single line of text this component will display.") public void setText(String text) { String oldAccessibleName = null; if (accessibleContext != null) { oldAccessibleName = accessibleContext.getAccessibleName();
*** 373,388 **** * * @param icon the default icon this component will display * @see #setVerticalTextPosition * @see #setHorizontalTextPosition * @see #getIcon - * @beaninfo - * preferred: true - * bound: true - * attribute: visualUpdate true - * description: The icon this component will display. */ public void setIcon(Icon icon) { Icon oldValue = defaultIcon; defaultIcon = icon; /* If the default icon has really changed and we had --- 361,373 ---- * * @param icon the default icon this component will display * @see #setVerticalTextPosition * @see #setHorizontalTextPosition * @see #getIcon */ + @BeanProperty(preferred = true, visualUpdate = true, description + = "The icon this component will display.") public void setIcon(Icon icon) { Icon oldValue = defaultIcon; defaultIcon = icon; /* If the default icon has really changed and we had
*** 450,464 **** * The default value of this property is null. * * @param disabledIcon the Icon to display when the component is disabled * @see #getDisabledIcon * @see #setEnabled - * @beaninfo - * bound: true - * attribute: visualUpdate true - * description: The icon to display if the label is disabled. */ public void setDisabledIcon(Icon disabledIcon) { Icon oldValue = this.disabledIcon; this.disabledIcon = disabledIcon; disabledIconSet = (disabledIcon != null); firePropertyChange("disabledIcon", oldValue, disabledIcon); --- 435,447 ---- * The default value of this property is null. * * @param disabledIcon the Icon to display when the component is disabled * @see #getDisabledIcon * @see #setEnabled */ + @BeanProperty(visualUpdate = true, description + = "The icon to display if the label is disabled.") public void setDisabledIcon(Icon disabledIcon) { Icon oldValue = this.disabledIcon; this.disabledIcon = disabledIcon; disabledIconSet = (disabledIcon != null); firePropertyChange("disabledIcon", oldValue, disabledIcon);
*** 483,497 **** * labelFor property when the mnemonic is activated. * * @param key a keycode that indicates a mnemonic key * @see #getLabelFor * @see #setLabelFor - * @beaninfo - * bound: true - * attribute: visualUpdate true - * description: The mnemonic keycode. */ public void setDisplayedMnemonic(int key) { int oldKey = mnemonic; mnemonic = key; firePropertyChange("displayedMnemonic", oldKey, mnemonic); --- 466,478 ---- * labelFor property when the mnemonic is activated. * * @param key a keycode that indicates a mnemonic key * @see #getLabelFor * @see #setLabelFor */ + @BeanProperty(visualUpdate = true, description + = "The mnemonic keycode.") public void setDisplayedMnemonic(int key) { int oldKey = mnemonic; mnemonic = key; firePropertyChange("displayedMnemonic", oldKey, mnemonic);
*** 553,569 **** * * @since 1.4 * @param index Index into the String to underline * @exception IllegalArgumentException will be thrown if <code>index</code> * is &gt;= length of the text, or &lt; -1 - * - * @beaninfo - * bound: true - * attribute: visualUpdate true - * description: the index into the String to draw the keyboard character - * mnemonic at */ public void setDisplayedMnemonicIndex(int index) throws IllegalArgumentException { int oldValue = mnemonicIndex; if (index == -1) { mnemonicIndex = -1; --- 534,546 ---- * * @since 1.4 * @param index Index into the String to underline * @exception IllegalArgumentException will be thrown if <code>index</code> * is &gt;= length of the text, or &lt; -1 */ + @BeanProperty(visualUpdate = true, description + = "the index into the String to draw the keyboard character mnemonic at") public void setDisplayedMnemonicIndex(int index) throws IllegalArgumentException { int oldValue = mnemonicIndex; if (index == -1) { mnemonicIndex = -1;
*** 663,678 **** * <p> * This is a JavaBeans bound property. * * @param iconTextGap the space between the icon and text properties * @see #getIconTextGap - * @beaninfo - * bound: true - * attribute: visualUpdate true - * description: If both the icon and text properties are set, this - * property defines the space between them. */ public void setIconTextGap(int iconTextGap) { int oldValue = this.iconTextGap; this.iconTextGap = iconTextGap; firePropertyChange("iconTextGap", oldValue, iconTextGap); if (iconTextGap != oldValue) { --- 640,652 ---- * <p> * This is a JavaBeans bound property. * * @param iconTextGap the space between the icon and text properties * @see #getIconTextGap */ + @BeanProperty(visualUpdate = true, description + = "If both the icon and text properties are set, this property defines the space between them.") public void setIconTextGap(int iconTextGap) { int oldValue = this.iconTextGap; this.iconTextGap = iconTextGap; firePropertyChange("iconTextGap", oldValue, iconTextGap); if (iconTextGap != oldValue) {
*** 711,728 **** * <code>CENTER</code> (the default), or * <code>BOTTOM</code>. * * @see SwingConstants * @see #getVerticalAlignment - * @beaninfo - * bound: true - * enum: TOP SwingConstants.TOP - * CENTER SwingConstants.CENTER - * BOTTOM SwingConstants.BOTTOM - * attribute: visualUpdate true - * description: The alignment of the label's contents along the Y axis. */ public void setVerticalAlignment(int alignment) { if (alignment == verticalAlignment) return; int oldValue = verticalAlignment; verticalAlignment = checkVerticalKey(alignment, "verticalAlignment"); firePropertyChange("verticalAlignment", oldValue, verticalAlignment); --- 685,700 ---- * <code>CENTER</code> (the default), or * <code>BOTTOM</code>. * * @see SwingConstants * @see #getVerticalAlignment */ + @BeanProperty(visualUpdate = true, enumerationValues = { + "SwingConstants.TOP", + "SwingConstants.CENTER", + "SwingConstants.BOTTOM"}, + description = "The alignment of the label's contents along the Y axis.") public void setVerticalAlignment(int alignment) { if (alignment == verticalAlignment) return; int oldValue = verticalAlignment; verticalAlignment = checkVerticalKey(alignment, "verticalAlignment"); firePropertyChange("verticalAlignment", oldValue, verticalAlignment);
*** 761,780 **** * <code>LEADING</code> (the default for text-only labels) or * <code>TRAILING</code>. * * @see SwingConstants * @see #getHorizontalAlignment - * @beaninfo - * bound: true - * enum: LEFT SwingConstants.LEFT - * CENTER SwingConstants.CENTER - * RIGHT SwingConstants.RIGHT - * LEADING SwingConstants.LEADING - * TRAILING SwingConstants.TRAILING - * attribute: visualUpdate true - * description: The alignment of the label's content along the X axis. */ public void setHorizontalAlignment(int alignment) { if (alignment == horizontalAlignment) return; int oldValue = horizontalAlignment; horizontalAlignment = checkHorizontalKey(alignment, "horizontalAlignment"); --- 733,750 ---- * <code>LEADING</code> (the default for text-only labels) or * <code>TRAILING</code>. * * @see SwingConstants * @see #getHorizontalAlignment */ + @BeanProperty(visualUpdate = true, enumerationValues = { + "SwingConstants.LEFT", + "SwingConstants.CENTER", + "SwingConstants.RIGHT", + "SwingConstants.LEADING", + "SwingConstants.TRAILING"}, description + = "The alignment of the label's content along the X axis.") public void setHorizontalAlignment(int alignment) { if (alignment == horizontalAlignment) return; int oldValue = horizontalAlignment; horizontalAlignment = checkHorizontalKey(alignment, "horizontalAlignment");
*** 816,834 **** * <code>CENTER</code> (the default), or * <code>BOTTOM</code>. * * @see SwingConstants * @see #getVerticalTextPosition - * @beaninfo - * bound: true - * enum: TOP SwingConstants.TOP - * CENTER SwingConstants.CENTER - * BOTTOM SwingConstants.BOTTOM - * expert: true - * attribute: visualUpdate true - * description: The vertical position of the text relative to it's image. */ public void setVerticalTextPosition(int textPosition) { if (textPosition == verticalTextPosition) return; int old = verticalTextPosition; verticalTextPosition = checkVerticalKey(textPosition, "verticalTextPosition"); --- 786,801 ---- * <code>CENTER</code> (the default), or * <code>BOTTOM</code>. * * @see SwingConstants * @see #getVerticalTextPosition */ + @BeanProperty(expert = true, visualUpdate = true, enumerationValues = { + "SwingConstants.TOP", + "SwingConstants.CENTER", + "SwingConstants.BOTTOM"}, + description = "The vertical position of the text relative to it's image.") public void setVerticalTextPosition(int textPosition) { if (textPosition == verticalTextPosition) return; int old = verticalTextPosition; verticalTextPosition = checkVerticalKey(textPosition, "verticalTextPosition");
*** 868,889 **** * <code>RIGHT</code>, * <code>LEADING</code>, or * <code>TRAILING</code> (the default). * * @see SwingConstants - * @beaninfo - * expert: true - * bound: true - * enum: LEFT SwingConstants.LEFT - * CENTER SwingConstants.CENTER - * RIGHT SwingConstants.RIGHT - * LEADING SwingConstants.LEADING - * TRAILING SwingConstants.TRAILING - * attribute: visualUpdate true - * description: The horizontal position of the label's text, - * relative to its image. */ public void setHorizontalTextPosition(int textPosition) { int old = horizontalTextPosition; this.horizontalTextPosition = checkHorizontalKey(textPosition, "horizontalTextPosition"); firePropertyChange("horizontalTextPosition", --- 835,852 ---- * <code>RIGHT</code>, * <code>LEADING</code>, or * <code>TRAILING</code> (the default). * * @see SwingConstants */ + @BeanProperty(expert = true, visualUpdate = true, enumerationValues = { + "SwingConstants.LEFT", + "SwingConstants.CENTER", + "SwingConstants.RIGHT", + "SwingConstants.LEADING", + "SwingConstants.TRAILING"}, description + = "The horizontal position of the label's text, relative to its image.") public void setHorizontalTextPosition(int textPosition) { int old = horizontalTextPosition; this.horizontalTextPosition = checkHorizontalKey(textPosition, "horizontalTextPosition"); firePropertyChange("horizontalTextPosition",
*** 1033,1047 **** * @param c the Component this label is for, or null if the label is * not the label for a component * * @see #getDisplayedMnemonic * @see #setDisplayedMnemonic - * - * @beaninfo - * bound: true - * description: The component this is labelling. */ public void setLabelFor(Component c) { Component oldC = labelFor; labelFor = c; firePropertyChange("labelFor", oldC, c); --- 996,1008 ---- * @param c the Component this label is for, or null if the label is * not the label for a component * * @see #getDisplayedMnemonic * @see #setDisplayedMnemonic */ + @BeanProperty(description + = "The component this is labelling.") public void setLabelFor(Component c) { Component oldC = labelFor; labelFor = c; firePropertyChange("labelFor", oldC, c);
*** 1055,1068 **** /** * Get the AccessibleContext of this object * * @return the AccessibleContext of this object - * @beaninfo - * expert: true - * description: The AccessibleContext associated with this Label. */ public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJLabel(); } return accessibleContext; --- 1016,1028 ---- /** * Get the AccessibleContext of this object * * @return the AccessibleContext of this object */ + @BeanProperty(bound = false, expert = true, description + = "The AccessibleContext associated with this Label.") public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJLabel(); } return accessibleContext;