2362N/A * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A display area for a short text string or an image, 0N/A * A label does not react to input events. 0N/A * As a result, it cannot get the keyboard focus. 0N/A * A label can, however, display a keyboard alternative 0N/A * as a convenience for a nearby component 0N/A * that has a keyboard alternative but can't display it. 0N/A * A <code>JLabel</code> object can display 0N/A * either text, an image, or both. 0N/A * You can specify where in the label's display area 0N/A * the label's contents are aligned 0N/A * by setting the vertical and horizontal alignment. 0N/A * By default, labels are vertically centered 0N/A * in their display area. 0N/A * Text-only labels are leading edge aligned, by default; 0N/A * image-only labels are horizontally centered, by default. 0N/A * You can also specify the position of the text 0N/A * relative to the image. 0N/A * By default, text is on the trailing edge of the image, 0N/A * with the text and image vertically aligned. 0N/A * A label's leading and trailing edge are determined from the value of its 0N/A * {@link java.awt.ComponentOrientation} property. At present, the default 0N/A * ComponentOrientation setting maps the leading edge to left and the trailing 0N/A * Finally, you can use the <code>setIconTextGap</code> method 0N/A * to specify how many pixels 0N/A * should appear between the text and the image. 0N/A * The default is 4 pixels. 0N/A * in <em>The Java Tutorial</em> 0N/A * for further documentation. 0N/A * <strong>Warning:</strong> Swing is not thread safe. For more 0N/A * information see <a 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * attribute: isContainer false 0N/A * description: A component that displays a short string and an icon. 0N/A * @author Hans Muller 0N/A * @see #getUIClassID 0N/A * Client property key used to determine what label is labeling the 0N/A * component. This is generally not used by labels, but is instead 0N/A * used by components such as text areas that are being labeled by 0N/A * labels. When the labelFor property of a label is set, it will 0N/A * automatically set the LABELED_BY_PROPERTY of the component being 0N/A * Creates a <code>JLabel</code> instance with the specified 0N/A * text, image, and horizontal alignment. 0N/A * The label is centered vertically in its display area. 0N/A * The text is on the trailing edge of the image. 0N/A * @param text The text to be displayed by the label. 0N/A * @param icon The image to be displayed by the label. 0N/A * @param horizontalAlignment One of the following constants 0N/A * defined in <code>SwingConstants</code>: 0N/A * <code>LEFT</code>, 0N/A * <code>CENTER</code>, 0N/A * <code>RIGHT</code>, 0N/A * <code>LEADING</code> or 0N/A * <code>TRAILING</code>. 0N/A * Creates a <code>JLabel</code> instance with the specified 0N/A * text and horizontal alignment. 0N/A * The label is centered vertically in its display area. 0N/A * @param text The text to be displayed by the label. 0N/A * @param horizontalAlignment One of the following constants 0N/A * defined in <code>SwingConstants</code>: 0N/A * <code>LEFT</code>, 0N/A * <code>CENTER</code>, 0N/A * <code>RIGHT</code>, 0N/A * <code>LEADING</code> or 0N/A * <code>TRAILING</code>. 0N/A * Creates a <code>JLabel</code> instance with the specified text. 0N/A * The label is aligned against the leading edge of its display area, 0N/A * and centered vertically. 0N/A * @param text The text to be displayed by the label. 0N/A * Creates a <code>JLabel</code> instance with the specified 0N/A * image and horizontal alignment. 0N/A * The label is centered vertically in its display area. 0N/A * @param image The image to be displayed by the label. 0N/A * @param horizontalAlignment One of the following constants 0N/A * defined in <code>SwingConstants</code>: 0N/A * <code>LEFT</code>, 0N/A * <code>CENTER</code>, 0N/A * <code>RIGHT</code>, 0N/A * <code>LEADING</code> or 0N/A * <code>TRAILING</code>. 0N/A * Creates a <code>JLabel</code> instance with the specified image. 0N/A * The label is centered vertically and horizontally 0N/A * in its display area. 0N/A * @param image The image to be displayed by the label. 0N/A * Creates a <code>JLabel</code> instance with 0N/A * no image and with an empty string for the title. 0N/A * The label is centered vertically 0N/A * in its display area. 0N/A * The label's contents, once set, will be displayed on the leading edge 0N/A * of the label's display area. 0N/A * Returns the L&F object that renders this component. 0N/A * @return LabelUI object 0N/A * Sets the L&F object that renders this component. 0N/A * @param ui the LabelUI L&F object 0N/A * @see UIDefaults#getUI 0N/A * attribute: visualUpdate true 0N/A * description: The UI object that implements the Component's LookAndFeel. 0N/A // disabled icon is generated by LF so it should be unset here 0N/A * Resets the UI property to a value from the current look and feel. 0N/A * @see JComponent#updateUI 0N/A * Returns a string that specifies the name of the l&f class 0N/A * that renders this component. 0N/A * @return String "LabelUI" 0N/A * @see JComponent#getUIClassID 0N/A * @see UIDefaults#getUI 0N/A * Returns the text string that the label displays. 0N/A * Defines the single line of text this component will display. If 0N/A * the value of text is null or empty string, nothing is displayed. 0N/A * The default value of this property is null. 0N/A * This is a JavaBeans bound property. 0N/A * @see #setVerticalTextPosition 0N/A * @see #setHorizontalTextPosition 0N/A * attribute: visualUpdate true 0N/A * description: Defines the single line of text this component will display. 0N/A * Returns the graphic image (glyph, icon) that the label displays. 0N/A * Defines the icon this component will display. If 0N/A * the value of icon is null, nothing is displayed. 0N/A * The default value of this property is null. 0N/A * This is a JavaBeans bound property. 0N/A * @see #setVerticalTextPosition 0N/A * @see #setHorizontalTextPosition 0N/A * attribute: visualUpdate true 0N/A * description: The icon this component will display. 0N/A /* If the default icon has really changed and we had 0N/A * generated the disabled icon for this component 0N/A * (in other words, setDisabledIcon() was never called), then 0N/A * clear the disabledIcon field. 0N/A /* If the default icon has changed and the new one is 0N/A * a different size, then revalidate. Repaint if the 0N/A * default icon has changed. 0N/A * Returns the icon used by the label when it's disabled. 0N/A * If no disabled icon has been set this will forward the call to 0N/A * the look and feel to construct an appropriate disabled Icon. 0N/A * Some look and feels might not render the disabled Icon, in which 0N/A * case they will ignore this. 0N/A * @return the <code>disabledIcon</code> property 0N/A * @see #setDisabledIcon 0N/A * @see javax.swing.LookAndFeel#getDisabledIcon 0N/A * Set the icon to be displayed if this JLabel is "disabled" 0N/A * (JLabel.setEnabled(false)). 0N/A * The default value of this property is null. 0N/A * @param disabledIcon the Icon to display when the component is disabled 0N/A * @see #getDisabledIcon 0N/A * attribute: visualUpdate true 0N/A * description: The icon to display if the label is disabled. 0N/A * Specify a keycode that indicates a mnemonic key. 0N/A * This property is used when the label is part of a larger component. 0N/A * If the labelFor property of the label is not null, the label will 0N/A * call the requestFocus method of the component specified by the 0N/A * labelFor property when the mnemonic is activated. 0N/A * attribute: visualUpdate true 0N/A * description: The mnemonic keycode. 0N/A * Specifies the displayedMnemonic as a char value. 0N/A * @param aChar a char specifying the mnemonic to display 0N/A * @see #setDisplayedMnemonic(int) 0N/A * Return the keycode that indicates a mnemonic key. 0N/A * This property is used when the label is part of a larger component. 0N/A * If the labelFor property of the label is not null, the label will 0N/A * call the requestFocus method of the component specified by the 0N/A * labelFor property when the mnemonic is activated. 0N/A * @return int value for the mnemonic key 0N/A * Provides a hint to the look and feel as to which character in the 0N/A * text should be decorated to represent the mnemonic. Not all look and 0N/A * feels may support this. A value of -1 indicates either there is no 0N/A * mnemonic, the mnemonic character is not contained in the string, or 0N/A * the developer does not wish the mnemonic to be displayed. 0N/A * The value of this is updated as the properties relating to the 0N/A * mnemonic change (such as the mnemonic itself, the text...). 0N/A * You should only ever have to call this if 0N/A * you do not wish the default character to be underlined. For example, if 0N/A * the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A' 0N/A * to be decorated, as 'Save <u>A</u>s', you would have to invoke 0N/A * <code>setDisplayedMnemonicIndex(5)</code> after invoking 0N/A * <code>setDisplayedMnemonic(KeyEvent.VK_A)</code>. 0N/A * @param index Index into the String to underline 0N/A * @exception IllegalArgumentException will be thrown if <code>index</code 0N/A * is >= length of the text, or < -1 0N/A * attribute: visualUpdate true 0N/A * description: the index into the String to draw the keyboard character 0N/A * Returns the character, as an index, that the look and feel should 0N/A * provide decoration for as representing the mnemonic character. 0N/A * @return index representing mnemonic character 0N/A * @see #setDisplayedMnemonicIndex 0N/A * Verify that key is a legal value for the horizontalAlignment properties. 0N/A * @param key the property value to check 0N/A * @param message the IllegalArgumentException detail message 0N/A * @exception IllegalArgumentException if key isn't LEFT, CENTER, RIGHT, 0N/A * LEADING or TRAILING. 0N/A * @see #setHorizontalTextPosition 0N/A * @see #setHorizontalAlignment 0N/A * Verify that key is a legal value for the 0N/A * verticalAlignment or verticalTextPosition properties. 0N/A * @param key the property value to check 0N/A * @param message the IllegalArgumentException detail message 0N/A * @exception IllegalArgumentException if key isn't TOP, CENTER, or BOTTOM. 0N/A * @see #setVerticalAlignment 0N/A * @see #setVerticalTextPosition 0N/A * Returns the amount of space between the text and the icon 0N/A * displayed in this label. 0N/A * @return an int equal to the number of pixels between the text 0N/A * @see #setIconTextGap 0N/A * If both the icon and text properties are set, this property 0N/A * defines the space between them. 0N/A * The default value of this property is 4 pixels. 0N/A * This is a JavaBeans bound property. 0N/A * @see #getIconTextGap 0N/A * attribute: visualUpdate true 0N/A * description: If both the icon and text properties are set, this 0N/A * property defines the space between them. 0N/A * Returns the alignment of the label's contents along the Y axis. 0N/A * @return The value of the verticalAlignment property, one of the 0N/A * following constants defined in <code>SwingConstants</code>: 0N/A * <code>CENTER</code>, or 0N/A * <code>BOTTOM</code>. 0N/A * @see SwingConstants 0N/A * @see #setVerticalAlignment 0N/A * Sets the alignment of the label's contents along the Y axis. 0N/A * The default value of this property is CENTER. 0N/A * @param alignment One of the following constants 0N/A * defined in <code>SwingConstants</code>: 0N/A * <code>CENTER</code> (the default), or 0N/A * <code>BOTTOM</code>. 0N/A * @see SwingConstants 0N/A * @see #getVerticalAlignment 0N/A * enum: TOP SwingConstants.TOP 0N/A * CENTER SwingConstants.CENTER 0N/A * BOTTOM SwingConstants.BOTTOM 0N/A * attribute: visualUpdate true 0N/A * description: The alignment of the label's contents along the Y axis. 0N/A * Returns the alignment of the label's contents along the X axis. 0N/A * @return The value of the horizontalAlignment property, one of the 0N/A * following constants defined in <code>SwingConstants</code>: 0N/A * <code>LEFT</code>, 0N/A * <code>CENTER</code>, 0N/A * <code>RIGHT</code>, 0N/A * <code>LEADING</code> or 0N/A * <code>TRAILING</code>. 0N/A * @see #setHorizontalAlignment 0N/A * @see SwingConstants 0N/A * Sets the alignment of the label's contents along the X axis. 0N/A * This is a JavaBeans bound property. 0N/A * @param alignment One of the following constants 0N/A * defined in <code>SwingConstants</code>: 0N/A * <code>LEFT</code>, 0N/A * <code>CENTER</code> (the default for image-only labels), 0N/A * <code>RIGHT</code>, 0N/A * <code>LEADING</code> (the default for text-only labels) or 0N/A * <code>TRAILING</code>. 0N/A * @see SwingConstants 0N/A * @see #getHorizontalAlignment 0N/A * enum: LEFT SwingConstants.LEFT 0N/A * CENTER SwingConstants.CENTER 0N/A * RIGHT SwingConstants.RIGHT 0N/A * LEADING SwingConstants.LEADING 0N/A * TRAILING SwingConstants.TRAILING 0N/A * attribute: visualUpdate true 0N/A * description: The alignment of the label's content along the X axis. 0N/A "horizontalAlignment");
0N/A * Returns the vertical position of the label's text, 0N/A * relative to its image. 0N/A * @return One of the following constants 0N/A * defined in <code>SwingConstants</code>: 0N/A * <code>CENTER</code>, or 0N/A * <code>BOTTOM</code>. 0N/A * @see #setVerticalTextPosition 0N/A * @see SwingConstants 0N/A * Sets the vertical position of the label's text, 0N/A * relative to its image. 0N/A * The default value of this property is CENTER. 0N/A * This is a JavaBeans bound property. 0N/A * @param textPosition One of the following constants 0N/A * defined in <code>SwingConstants</code>: 0N/A * <code>CENTER</code> (the default), or 0N/A * <code>BOTTOM</code>. 0N/A * @see SwingConstants 0N/A * @see #getVerticalTextPosition 0N/A * enum: TOP SwingConstants.TOP 0N/A * CENTER SwingConstants.CENTER 0N/A * BOTTOM SwingConstants.BOTTOM 0N/A * attribute: visualUpdate true 0N/A * description: The vertical position of the text relative to it's image. 0N/A "verticalTextPosition");
0N/A * Returns the horizontal position of the label's text, 0N/A * relative to its image. 0N/A * @return One of the following constants 0N/A * defined in <code>SwingConstants</code>: 0N/A * <code>LEFT</code>, 0N/A * <code>CENTER</code>, 0N/A * <code>RIGHT</code>, 0N/A * <code>LEADING</code> or 0N/A * <code>TRAILING</code>. 0N/A * @see SwingConstants 0N/A * Sets the horizontal position of the label's text, 0N/A * relative to its image. 0N/A * @param textPosition One of the following constants 0N/A * defined in <code>SwingConstants</code>: 0N/A * <code>LEFT</code>, 0N/A * <code>CENTER</code>, 0N/A * <code>RIGHT</code>, 0N/A * <code>LEADING</code>, or 0N/A * <code>TRAILING</code> (the default). 0N/A * @exception IllegalArgumentException 0N/A * @see SwingConstants 0N/A * enum: LEFT SwingConstants.LEFT 0N/A * CENTER SwingConstants.CENTER 0N/A * RIGHT SwingConstants.RIGHT 0N/A * LEADING SwingConstants.LEADING 0N/A * TRAILING SwingConstants.TRAILING 0N/A * attribute: visualUpdate true 0N/A * description: The horizontal position of the label's text, 0N/A * relative to its image. 0N/A "horizontalTextPosition");
0N/A * This is overridden to return false if the current Icon's Image is 0N/A * not equal to the passed in Image <code>img</code>. 0N/A * @see java.awt.image.ImageObserver 0N/A * @see java.awt.Component#imageUpdate(java.awt.Image, int, int, int, int, int) 0N/A int x,
int y,
int w,
int h) {
0N/A // Don't use getDisabledIcon, will trigger creation of icon if icon 0N/A * See readObject() and writeObject() in JComponent for more 0N/A * information about serialization in Swing. 0N/A * Returns a string representation of this JLabel. This method 0N/A * is intended to be used only for debugging purposes, and the 0N/A * content and format of the returned string may vary between 0N/A * implementations. The returned string may be empty but may not 0N/A * be <code>null</code>. 0N/A * @return a string representation of this JLabel. 0N/A * --- Accessibility Support --- 0N/A * Get the component this is labelling. 0N/A * @return the Component this is labelling. Can be null if this 0N/A * does not label a Component. If the displayedMnemonic 0N/A * property is set and the labelFor property is also set, the label 0N/A * will call the requestFocus method of the component specified by the 0N/A * labelFor property when the mnemonic is activated. 0N/A * @see #getDisplayedMnemonic 0N/A * @see #setDisplayedMnemonic 0N/A * Set the component this is labelling. Can be null if this does not 0N/A * label a Component. If the displayedMnemonic property is set 0N/A * and the labelFor property is also set, the label will 0N/A * call the requestFocus method of the component specified by the 0N/A * labelFor property when the mnemonic is activated. 0N/A * @param c the Component this label is for, or null if the label is 0N/A * not the label for a component 0N/A * @see #getDisplayedMnemonic 0N/A * @see #setDisplayedMnemonic 0N/A * description: The component this is labelling. 0N/A * Get the AccessibleContext of this object 0N/A * @return the AccessibleContext of this object 0N/A * description: The AccessibleContext associated with this Label. 0N/A * The class used to obtain the accessible role for this object. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * Get the accessible name of this object. 0N/A * @return the localized name of the object -- can be null if this 0N/A * object does not have a name 0N/A * @see AccessibleContext#setAccessibleName 0N/A * Get the role of this object. 0N/A * @return an instance of AccessibleRole describing the role of the 0N/A * @see AccessibleRole 0N/A * Get the AccessibleIcons associated with this object if one 0N/A * or more exist. Otherwise return null. 0N/A * Get the AccessibleRelationSet associated with this object if one 0N/A * exists. Otherwise return null. 0N/A * @see AccessibleRelation 0N/A // Check where the AccessibleContext's relation 0N/A // set already contains a LABEL_FOR relation. 0N/A /* AccessibleText ---------- */ 0N/A * Given a point in local coordinates, return the zero-based index 0N/A * of the character under that Point. If the point is invalid, 0N/A * this method returns -1. 0N/A * @param p the Point in local coordinates 0N/A * @return the zero-based index of the character under Point p; if 0N/A * Point is invalid returns -1. 0N/A * Determine the bounding box of the character at the given 0N/A * index into the string. The bounds are returned in local 0N/A * coordinates. If the index is invalid an empty rectangle is 0N/A * @param i the index into the String 0N/A * @return the screen coordinates of the character's the bounding box, 0N/A * if index is invalid returns an empty rectangle. 0N/A * Return the number of characters (valid indicies) 0N/A * @return the number of characters 0N/A * Return the zero-based offset of the caret. 0N/A * Note: That to the right of the caret will have the same index 0N/A * value as the offset (the caret is between two characters). 0N/A * @return the zero-based offset of the caret. 0N/A // There is no caret. 0N/A * Returns the String at a given index. 0N/A * @param part the AccessibleText.CHARACTER, AccessibleText.WORD, 0N/A * or AccessibleText.SENTENCE to retrieve 0N/A * @param index an index within the text >= 0 0N/A * @return the letter, word, or sentence, 0N/A * null for an invalid index or part 0N/A * Returns the String after a given index. 0N/A * @param part the AccessibleText.CHARACTER, AccessibleText.WORD, 0N/A * or AccessibleText.SENTENCE to retrieve 0N/A * @param index an index within the text >= 0 0N/A * @return the letter, word, or sentence, null for an invalid 0N/A * Returns the String before a given index. 0N/A * @param part the AccessibleText.CHARACTER, AccessibleText.WORD, 0N/A * or AccessibleText.SENTENCE to retrieve 0N/A * @param index an index within the text >= 0 0N/A * @return the letter, word, or sentence, null for an invalid index 0N/A * Return the AttributeSet for a given character at a given index 0N/A * @param i the zero-based index into the text 0N/A * @return the AttributeSet of the character 0N/A * Returns the start offset within the selected text. 0N/A * If there is no selection, but there is 0N/A * a caret, the start and end offsets will be the same. 0N/A * @return the index into the text of the start of the selection 0N/A // Text cannot be selected. 0N/A * Returns the end offset within the selected text. 0N/A * If there is no selection, but there is 0N/A * a caret, the start and end offsets will be the same. 0N/A * @return the index into teh text of the end of the selection 0N/A // Text cannot be selected. 0N/A * Returns the portion of the text that is selected. 0N/A * @return the String portion of the text that is selected 0N/A // Text cannot be selected. 0N/A * Returns the text substring starting at the specified 0N/A * offset with the specified length. 0N/A * Returns the bounding rectangle for the component text. 0N/A // ----- AccessibleExtendedComponent 0N/A * Returns the AccessibleExtendedComponent 0N/A * @return the AccessibleExtendedComponent 0N/A * Returns the tool tip text 0N/A * @return the tool tip text, if supported, of the object; 0N/A * Returns the titled border text 0N/A * @return the titled border text, if supported, of the object; 0N/A * Returns key bindings associated with this object 0N/A * @return the key bindings, if supported, of the object; 0N/A * @see AccessibleKeyBinding 0N/A * Returns the number of key bindings for this object 0N/A * @return the zero-based number of key bindings for this object 0N/A * Returns a key binding for this object. The value returned is an 0N/A * java.lang.Object which must be cast to appropriate type depending 0N/A * on the underlying implementation of the key. For example, if the 0N/A * Object returned is a javax.swing.KeyStroke, the user of this 0N/A * method should do the following: 0N/A * Component c = <get the component that has the key bindings> 0N/A * AccessibleContext ac = c.getAccessibleContext(); 0N/A * AccessibleKeyBinding akb = ac.getAccessibleKeyBinding(); 0N/A * for (int i = 0; i < akb.getAccessibleKeyBindingCount(); i++) { 0N/A * Object o = akb.getAccessibleKeyBinding(i); 0N/A * if (o instanceof javax.swing.KeyStroke) { 0N/A * javax.swing.KeyStroke keyStroke = (javax.swing.KeyStroke)o; 0N/A * <do something with the key binding> 0N/A * @param i zero-based index of the key bindings 0N/A * @return a javax.lang.Object which specifies the key binding 0N/A * @exception IllegalArgumentException if the index is 0N/A * @see #getAccessibleKeyBindingCount 0N/A }
// AccessibleJComponent