72 * <p>
73 * Finally, you can use the <code>setIconTextGap</code> method
74 * to specify how many pixels
75 * should appear between the text and the image.
76 * The default is 4 pixels.
77 * <p>
78 * See <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/label.html">How to Use Labels</a>
79 * in <em>The Java Tutorial</em>
80 * for further documentation.
81 * <p>
82 * <strong>Warning:</strong> Swing is not thread safe. For more
83 * information see <a
84 * href="package-summary.html#threading">Swing's Threading
85 * Policy</a>.
86 * <p>
87 * <strong>Warning:</strong>
88 * Serialized objects of this class will not be compatible with
89 * future Swing releases. The current serialization support is
90 * appropriate for short term storage or RMI between applications running
91 * the same version of Swing. As of 1.4, support for long term storage
92 * of all JavaBeans™
93 * has been added to the <code>java.beans</code> package.
94 * Please see {@link java.beans.XMLEncoder}.
95 *
96 * @author Hans Muller
97 * @since 1.2
98 */
99 @JavaBean(defaultProperty = "UI", description = "A component that displays a short string and an icon.")
100 @SwingContainer(false)
101 @SuppressWarnings("serial")
102 public class JLabel extends JComponent implements SwingConstants, Accessible
103 {
104 /**
105 * @see #getUIClassID
106 * @see #readObject
107 */
108 private static final String uiClassID = "LabelUI";
109
110 private int mnemonic = '\0';
111 private int mnemonicIndex = -1;
112
1018 *
1019 * @return the AccessibleContext of this object
1020 */
1021 @BeanProperty(bound = false, expert = true, description
1022 = "The AccessibleContext associated with this Label.")
1023 public AccessibleContext getAccessibleContext() {
1024 if (accessibleContext == null) {
1025 accessibleContext = new AccessibleJLabel();
1026 }
1027 return accessibleContext;
1028 }
1029
1030 /**
1031 * The class used to obtain the accessible role for this object.
1032 * <p>
1033 * <strong>Warning:</strong>
1034 * Serialized objects of this class will not be compatible with
1035 * future Swing releases. The current serialization support is
1036 * appropriate for short term storage or RMI between applications running
1037 * the same version of Swing. As of 1.4, support for long term storage
1038 * of all JavaBeans™
1039 * has been added to the <code>java.beans</code> package.
1040 * Please see {@link java.beans.XMLEncoder}.
1041 */
1042 @SuppressWarnings("serial")
1043 protected class AccessibleJLabel extends AccessibleJComponent
1044 implements AccessibleText, AccessibleExtendedComponent {
1045
1046 /**
1047 * Get the accessible name of this object.
1048 *
1049 * @return the localized name of the object -- can be null if this
1050 * object does not have a name
1051 * @see AccessibleContext#setAccessibleName
1052 */
1053 public String getAccessibleName() {
1054 String name = accessibleName;
1055
1056 if (name == null) {
1057 name = (String)getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY);
1058 }
|
72 * <p>
73 * Finally, you can use the <code>setIconTextGap</code> method
74 * to specify how many pixels
75 * should appear between the text and the image.
76 * The default is 4 pixels.
77 * <p>
78 * See <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/label.html">How to Use Labels</a>
79 * in <em>The Java Tutorial</em>
80 * for further documentation.
81 * <p>
82 * <strong>Warning:</strong> Swing is not thread safe. For more
83 * information see <a
84 * href="package-summary.html#threading">Swing's Threading
85 * Policy</a>.
86 * <p>
87 * <strong>Warning:</strong>
88 * Serialized objects of this class will not be compatible with
89 * future Swing releases. The current serialization support is
90 * appropriate for short term storage or RMI between applications running
91 * the same version of Swing. As of 1.4, support for long term storage
92 * of all JavaBeans
93 * has been added to the <code>java.beans</code> package.
94 * Please see {@link java.beans.XMLEncoder}.
95 *
96 * @author Hans Muller
97 * @since 1.2
98 */
99 @JavaBean(defaultProperty = "UI", description = "A component that displays a short string and an icon.")
100 @SwingContainer(false)
101 @SuppressWarnings("serial")
102 public class JLabel extends JComponent implements SwingConstants, Accessible
103 {
104 /**
105 * @see #getUIClassID
106 * @see #readObject
107 */
108 private static final String uiClassID = "LabelUI";
109
110 private int mnemonic = '\0';
111 private int mnemonicIndex = -1;
112
1018 *
1019 * @return the AccessibleContext of this object
1020 */
1021 @BeanProperty(bound = false, expert = true, description
1022 = "The AccessibleContext associated with this Label.")
1023 public AccessibleContext getAccessibleContext() {
1024 if (accessibleContext == null) {
1025 accessibleContext = new AccessibleJLabel();
1026 }
1027 return accessibleContext;
1028 }
1029
1030 /**
1031 * The class used to obtain the accessible role for this object.
1032 * <p>
1033 * <strong>Warning:</strong>
1034 * Serialized objects of this class will not be compatible with
1035 * future Swing releases. The current serialization support is
1036 * appropriate for short term storage or RMI between applications running
1037 * the same version of Swing. As of 1.4, support for long term storage
1038 * of all JavaBeans
1039 * has been added to the <code>java.beans</code> package.
1040 * Please see {@link java.beans.XMLEncoder}.
1041 */
1042 @SuppressWarnings("serial")
1043 protected class AccessibleJLabel extends AccessibleJComponent
1044 implements AccessibleText, AccessibleExtendedComponent {
1045
1046 /**
1047 * Get the accessible name of this object.
1048 *
1049 * @return the localized name of the object -- can be null if this
1050 * object does not have a name
1051 * @see AccessibleContext#setAccessibleName
1052 */
1053 public String getAccessibleName() {
1054 String name = accessibleName;
1055
1056 if (name == null) {
1057 name = (String)getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY);
1058 }
|