< prev index next >

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

Print this page

        

@@ -52,11 +52,11 @@
  * As a result, it cannot get the keyboard focus.
  * A label can, however, display a keyboard alternative
  * as a convenience for a nearby component
  * that has a keyboard alternative but can't display it.
  * <p>
- * A <code>JLabel</code> object can display
+ * A {@code JLabel} object can display
  * either text, an image, or both.
  * You can specify where in the label's display area
  * the label's contents are aligned
  * by setting the vertical and horizontal alignment.
  * By default, labels are vertically centered

@@ -73,11 +73,11 @@
  * {@link java.awt.ComponentOrientation} property.  At present, the default
  * ComponentOrientation setting maps the leading edge to left and the trailing
  * edge to right.
  *
  * <p>
- * Finally, you can use the <code>setIconTextGap</code> method
+ * Finally, you can use the {@code setIconTextGap} method
  * to specify how many pixels
  * should appear between the text and the image.
  * The default is 4 pixels.
  * <p>
  * See <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/label.html">How to Use Labels</a>

@@ -93,11 +93,11 @@
  * 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 JavaBeans&trade;
- * has been added to the <code>java.beans</code> package.
+ * has been added to the {@code java.beans} package.
  * Please see {@link java.beans.XMLEncoder}.
  *
  * @beaninfo
  *   attribute: isContainer false
  * description: A component that displays a short string and an icon.

@@ -145,93 +145,93 @@
      * @see #setLabelFor
      */
     static final String LABELED_BY_PROPERTY = "labeledBy";
 
     /**
-     * Creates a <code>JLabel</code> instance with the specified
+     * Creates a {@code JLabel} instance with the specified
      * text, image, and horizontal alignment.
      * The label is centered vertically in its display area.
      * The text is on the trailing edge of the image.
      *
      * @param text  The text to be displayed by the label.
      * @param icon  The image to be displayed by the label.
      * @param horizontalAlignment  One of the following constants
-     *           defined in <code>SwingConstants</code>:
-     *           <code>LEFT</code>,
-     *           <code>CENTER</code>,
-     *           <code>RIGHT</code>,
-     *           <code>LEADING</code> or
-     *           <code>TRAILING</code>.
+     *           defined in {@code SwingConstants}:
+     *           {@code LEFT},
+     *           {@code CENTER},
+     *           {@code RIGHT},
+     *           {@code LEADING} or
+     *           {@code TRAILING}.
      */
     public JLabel(String text, Icon icon, int horizontalAlignment) {
         setText(text);
         setIcon(icon);
         setHorizontalAlignment(horizontalAlignment);
         updateUI();
         setAlignmentX(LEFT_ALIGNMENT);
     }
 
     /**
-     * Creates a <code>JLabel</code> instance with the specified
+     * Creates a {@code JLabel} instance with the specified
      * text and horizontal alignment.
      * The label is centered vertically in its display area.
      *
      * @param text  The text to be displayed by the label.
      * @param horizontalAlignment  One of the following constants
-     *           defined in <code>SwingConstants</code>:
-     *           <code>LEFT</code>,
-     *           <code>CENTER</code>,
-     *           <code>RIGHT</code>,
-     *           <code>LEADING</code> or
-     *           <code>TRAILING</code>.
+     *           defined in {@code SwingConstants}:
+     *           {@code LEFT},
+     *           {@code CENTER},
+     *           {@code RIGHT},
+     *           {@code LEADING} or
+     *           {@code TRAILING}.
      */
     public JLabel(String text, int horizontalAlignment) {
         this(text, null, horizontalAlignment);
     }
 
     /**
-     * Creates a <code>JLabel</code> instance with the specified text.
+     * Creates a {@code JLabel} instance with the specified text.
      * The label is aligned against the leading edge of its display area,
      * and centered vertically.
      *
      * @param text  The text to be displayed by the label.
      */
     public JLabel(String text) {
         this(text, null, LEADING);
     }
 
     /**
-     * Creates a <code>JLabel</code> instance with the specified
+     * Creates a {@code JLabel} instance with the specified
      * image and horizontal alignment.
      * The label is centered vertically in its display area.
      *
      * @param image  The image to be displayed by the label.
      * @param horizontalAlignment  One of the following constants
-     *           defined in <code>SwingConstants</code>:
-     *           <code>LEFT</code>,
-     *           <code>CENTER</code>,
-     *           <code>RIGHT</code>,
-     *           <code>LEADING</code> or
-     *           <code>TRAILING</code>.
+     *           defined in {@code SwingConstants}:
+     *           {@code LEFT},
+     *           {@code CENTER},
+     *           {@code RIGHT},
+     *           {@code LEADING} or
+     *           {@code TRAILING}.
      */
     public JLabel(Icon image, int horizontalAlignment) {
         this(null, image, horizontalAlignment);
     }
 
     /**
-     * Creates a <code>JLabel</code> instance with the specified image.
+     * Creates a {@code JLabel} instance with the specified image.
      * The label is centered vertically and horizontally
      * in its display area.
      *
      * @param image  The image to be displayed by the label.
      */
     public JLabel(Icon image) {
         this(null, image, CENTER);
     }
 
     /**
-     * Creates a <code>JLabel</code> instance with
+     * Creates a {@code JLabel} instance with
      * no image and with an empty string for the title.
      * The label is centered vertically
      * in its display area.
      * The label's contents, once set, will be displayed on the leading edge
      * of the label's display area.

@@ -424,11 +424,11 @@
      * the look and feel to construct an appropriate disabled Icon.
      * <p>
      * Some look and feels might not render the disabled Icon, in which
      * case they will ignore this.
      *
-     * @return the <code>disabledIcon</code> property
+     * @return the {@code disabledIcon} property
      * @see #setDisabledIcon
      * @see javax.swing.LookAndFeel#getDisabledIcon
      * @see ImageIcon
      */
     @Transient

@@ -546,16 +546,16 @@
      * mnemonic change (such as the mnemonic itself, the text...).
      * You should only ever have to call this if
      * you do not wish the default character to be underlined. For example, if
      * the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A'
      * to be decorated, as 'Save <u>A</u>s', you would have to invoke
-     * <code>setDisplayedMnemonicIndex(5)</code> after invoking
-     * <code>setDisplayedMnemonic(KeyEvent.VK_A)</code>.
+     * {@code setDisplayedMnemonicIndex(5)} after invoking
+     * {@code setDisplayedMnemonic(KeyEvent.VK_A)}.
      *
      * @since 1.4
      * @param index Index into the String to underline
-     * @exception IllegalArgumentException will be thrown if <code>index</code>
+     * @exception IllegalArgumentException will be thrown if {@code index}
      *            is &gt;= length of the text, or &lt; -1
      *
      * @beaninfo
      *        bound: true
      *    attribute: visualUpdate true

@@ -685,14 +685,14 @@
 
     /**
      * Returns the alignment of the label's contents along the Y axis.
      *
      * @return   The value of the verticalAlignment property, one of the
-     *           following constants defined in <code>SwingConstants</code>:
-     *           <code>TOP</code>,
-     *           <code>CENTER</code>, or
-     *           <code>BOTTOM</code>.
+     *           following constants defined in {@code SwingConstants}:
+     *           {@code TOP},
+     *           {@code CENTER}, or
+     *           {@code BOTTOM}.
      *
      * @see SwingConstants
      * @see #setVerticalAlignment
      */
     public int getVerticalAlignment() {

@@ -704,14 +704,14 @@
      * Sets the alignment of the label's contents along the Y axis.
      * <p>
      * The default value of this property is CENTER.
      *
      * @param alignment One of the following constants
-     *           defined in <code>SwingConstants</code>:
-     *           <code>TOP</code>,
-     *           <code>CENTER</code> (the default), or
-     *           <code>BOTTOM</code>.
+     *           defined in {@code SwingConstants}:
+     *           {@code TOP},
+     *           {@code CENTER} (the default), or
+     *           {@code BOTTOM}.
      *
      * @see SwingConstants
      * @see #getVerticalAlignment
      * @beaninfo
      *        bound: true

@@ -732,16 +732,16 @@
 
     /**
      * Returns the alignment of the label's contents along the X axis.
      *
      * @return   The value of the horizontalAlignment property, one of the
-     *           following constants defined in <code>SwingConstants</code>:
-     *           <code>LEFT</code>,
-     *           <code>CENTER</code>,
-     *           <code>RIGHT</code>,
-     *           <code>LEADING</code> or
-     *           <code>TRAILING</code>.
+     *           following constants defined in {@code SwingConstants}:
+     *           {@code LEFT},
+     *           {@code CENTER},
+     *           {@code RIGHT},
+     *           {@code LEADING} or
+     *           {@code TRAILING}.
      *
      * @see #setHorizontalAlignment
      * @see SwingConstants
      */
     public int getHorizontalAlignment() {

@@ -752,16 +752,16 @@
      * Sets the alignment of the label's contents along the X axis.
      * <p>
      * This is a JavaBeans bound property.
      *
      * @param alignment  One of the following constants
-     *           defined in <code>SwingConstants</code>:
-     *           <code>LEFT</code>,
-     *           <code>CENTER</code> (the default for image-only labels),
-     *           <code>RIGHT</code>,
-     *           <code>LEADING</code> (the default for text-only labels) or
-     *           <code>TRAILING</code>.
+     *           defined in {@code SwingConstants}:
+     *           {@code LEFT},
+     *           {@code CENTER} (the default for image-only labels),
+     *           {@code RIGHT},
+     *           {@code LEADING} (the default for text-only labels) or
+     *           {@code TRAILING}.
      *
      * @see SwingConstants
      * @see #getHorizontalAlignment
      * @beaninfo
      *        bound: true

@@ -787,14 +787,14 @@
     /**
      * Returns the vertical position of the label's text,
      * relative to its image.
      *
      * @return   One of the following constants
-     *           defined in <code>SwingConstants</code>:
-     *           <code>TOP</code>,
-     *           <code>CENTER</code>, or
-     *           <code>BOTTOM</code>.
+     *           defined in {@code SwingConstants}:
+     *           {@code TOP},
+     *           {@code CENTER}, or
+     *           {@code BOTTOM}.
      *
      * @see #setVerticalTextPosition
      * @see SwingConstants
      */
     public int getVerticalTextPosition() {

@@ -809,14 +809,14 @@
      * The default value of this property is CENTER.
      * <p>
      * This is a JavaBeans bound property.
      *
      * @param textPosition  One of the following constants
-     *           defined in <code>SwingConstants</code>:
-     *           <code>TOP</code>,
-     *           <code>CENTER</code> (the default), or
-     *           <code>BOTTOM</code>.
+     *           defined in {@code SwingConstants}:
+     *           {@code TOP},
+     *           {@code CENTER} (the default), or
+     *           {@code BOTTOM}.
      *
      * @see SwingConstants
      * @see #getVerticalTextPosition
      * @beaninfo
      *        bound: true

@@ -841,16 +841,16 @@
     /**
      * Returns the horizontal position of the label's text,
      * relative to its image.
      *
      * @return   One of the following constants
-     *           defined in <code>SwingConstants</code>:
-     *           <code>LEFT</code>,
-     *           <code>CENTER</code>,
-     *           <code>RIGHT</code>,
-     *           <code>LEADING</code> or
-     *           <code>TRAILING</code>.
+     *           defined in {@code SwingConstants}:
+     *           {@code LEFT},
+     *           {@code CENTER},
+     *           {@code RIGHT},
+     *           {@code LEADING} or
+     *           {@code TRAILING}.
      *
      * @see SwingConstants
      */
     public int getHorizontalTextPosition() {
         return horizontalTextPosition;

@@ -860,16 +860,16 @@
     /**
      * Sets the horizontal position of the label's text,
      * relative to its image.
      *
      * @param textPosition  One of the following constants
-     *           defined in <code>SwingConstants</code>:
-     *           <code>LEFT</code>,
-     *           <code>CENTER</code>,
-     *           <code>RIGHT</code>,
-     *           <code>LEADING</code>, or
-     *           <code>TRAILING</code> (the default).
+     *           defined in {@code SwingConstants}:
+     *           {@code LEFT},
+     *           {@code CENTER},
+     *           {@code RIGHT},
+     *           {@code LEADING}, or
+     *           {@code TRAILING} (the default).
      *
      * @see SwingConstants
      * @beaninfo
      *       expert: true
      *        bound: true

@@ -893,11 +893,11 @@
     }
 
 
     /**
      * This is overridden to return false if the current Icon's Image is
-     * not equal to the passed in Image <code>img</code>.
+     * not equal to the passed in Image {@code img}.
      *
      * @see     java.awt.image.ImageObserver
      * @see     java.awt.Component#imageUpdate(java.awt.Image, int, int, int, int, int)
      */
     public boolean imageUpdate(Image img, int infoflags,

@@ -933,11 +933,11 @@
     /**
      * Returns a string representation of this JLabel. This method
      * is intended to be used only for debugging purposes, and the
      * content and format of the returned string may vary between
      * implementations. The returned string may be empty but may not
-     * be <code>null</code>.
+     * be {@code null}.
      *
      * @return  a string representation of this JLabel.
      */
     protected String paramString() {
         String textString = (text != null ?

@@ -1075,11 +1075,11 @@
      * 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 JavaBeans&trade;
-     * has been added to the <code>java.beans</code> package.
+     * has been added to the {@code java.beans} package.
      * Please see {@link java.beans.XMLEncoder}.
      */
     @SuppressWarnings("serial")
     protected class AccessibleJLabel extends AccessibleJComponent
         implements AccessibleText, AccessibleExtendedComponent {

@@ -1197,15 +1197,15 @@
         }
 
         /**
          * Returns the bounding box of the character at the given
          * index in the string.  The bounds are returned in local
-         * coordinates. If the index is invalid, <code>null</code> is returned.
+         * coordinates. If the index is invalid, {@code null} is returned.
          *
          * @param i the index into the String
          * @return the screen coordinates of the character's bounding box.
-         * If the index is invalid, <code>null</code> is returned.
+         * If the index is invalid, {@code null} is returned.
          * @since 1.3
          */
         public Rectangle getCharacterBounds(int i) {
             View view = (View) JLabel.this.getClientProperty("html");
             if (view != null) {

@@ -1615,22 +1615,22 @@
              * Returns a key binding for this object.  The value returned is an
              * java.lang.Object which must be cast to appropriate type depending
              * on the underlying implementation of the key.  For example, if the
              * Object returned is a javax.swing.KeyStroke, the user of this
              * method should do the following:
-             * <nf><code>
+             * <pre>{@code
              * Component c = <get the component that has the key bindings>
              * AccessibleContext ac = c.getAccessibleContext();
              * AccessibleKeyBinding akb = ac.getAccessibleKeyBinding();
              * for (int i = 0; i < akb.getAccessibleKeyBindingCount(); i++) {
              *     Object o = akb.getAccessibleKeyBinding(i);
              *     if (o instanceof javax.swing.KeyStroke) {
              *         javax.swing.KeyStroke keyStroke = (javax.swing.KeyStroke)o;
              *         <do something with the key binding>
              *     }
              * }
-             * </code></nf>
+             * }</pre>
              *
              * @param i zero-based index of the key bindings
              * @return a javax.lang.Object which specifies the key binding
              * @exception IllegalArgumentException if the index is
              * out of bounds
< prev index next >