src/share/classes/java/awt/Label.java

Print this page




 177         }
 178     }
 179 
 180     /**
 181      * Creates the peer for this label.  The peer allows us to
 182      * modify the appearance of the label without changing its
 183      * functionality.
 184      */
 185     public void addNotify() {
 186         synchronized (getTreeLock()) {
 187             if (peer == null)
 188                 peer = getToolkit().createLabel(this);
 189             super.addNotify();
 190         }
 191     }
 192 
 193     /**
 194      * Gets the current alignment of this label. Possible values are
 195      * <code>Label.LEFT</code>, <code>Label.RIGHT</code>, and
 196      * <code>Label.CENTER</code>.

 197      * @see        java.awt.Label#setAlignment
 198      */
 199     public int getAlignment() {
 200         return alignment;
 201     }
 202 
 203     /**
 204      * Sets the alignment for this label to the specified alignment.
 205      * Possible values are <code>Label.LEFT</code>,
 206      * <code>Label.RIGHT</code>, and <code>Label.CENTER</code>.
 207      * @param      alignment    the alignment to be set.
 208      * @exception  IllegalArgumentException if an improper value for
 209      *                          <code>alignment</code> is given.
 210      * @see        java.awt.Label#getAlignment
 211      */
 212     public synchronized void setAlignment(int alignment) {
 213         switch (alignment) {
 214           case LEFT:
 215           case CENTER:
 216           case RIGHT:


 305     public AccessibleContext getAccessibleContext() {
 306         if (accessibleContext == null) {
 307             accessibleContext = new AccessibleAWTLabel();
 308         }
 309         return accessibleContext;
 310     }
 311 
 312     /**
 313      * This class implements accessibility support for the
 314      * <code>Label</code> class.  It provides an implementation of the
 315      * Java Accessibility API appropriate to label user-interface elements.
 316      * @since 1.3
 317      */
 318     protected class AccessibleAWTLabel extends AccessibleAWTComponent
 319     {
 320         /*
 321          * JDK 1.3 serialVersionUID
 322          */
 323         private static final long serialVersionUID = -3568967560160480438L;
 324 



 325         public AccessibleAWTLabel() {
 326             super();
 327         }
 328 
 329         /**
 330          * Get the accessible name of this object.
 331          *
 332          * @return the localized name of the object -- can be null if this
 333          * object does not have a name
 334          * @see AccessibleContext#setAccessibleName
 335          */
 336         public String getAccessibleName() {
 337             if (accessibleName != null) {
 338                 return accessibleName;
 339             } else {
 340                 if (getText() == null) {
 341                     return super.getAccessibleName();
 342                 } else {
 343                     return getText();
 344                 }


 177         }
 178     }
 179 
 180     /**
 181      * Creates the peer for this label.  The peer allows us to
 182      * modify the appearance of the label without changing its
 183      * functionality.
 184      */
 185     public void addNotify() {
 186         synchronized (getTreeLock()) {
 187             if (peer == null)
 188                 peer = getToolkit().createLabel(this);
 189             super.addNotify();
 190         }
 191     }
 192 
 193     /**
 194      * Gets the current alignment of this label. Possible values are
 195      * <code>Label.LEFT</code>, <code>Label.RIGHT</code>, and
 196      * <code>Label.CENTER</code>.
 197      * @return the alignment of this label
 198      * @see java.awt.Label#setAlignment
 199      */
 200     public int getAlignment() {
 201         return alignment;
 202     }
 203 
 204     /**
 205      * Sets the alignment for this label to the specified alignment.
 206      * Possible values are <code>Label.LEFT</code>,
 207      * <code>Label.RIGHT</code>, and <code>Label.CENTER</code>.
 208      * @param      alignment    the alignment to be set.
 209      * @exception  IllegalArgumentException if an improper value for
 210      *                          <code>alignment</code> is given.
 211      * @see        java.awt.Label#getAlignment
 212      */
 213     public synchronized void setAlignment(int alignment) {
 214         switch (alignment) {
 215           case LEFT:
 216           case CENTER:
 217           case RIGHT:


 306     public AccessibleContext getAccessibleContext() {
 307         if (accessibleContext == null) {
 308             accessibleContext = new AccessibleAWTLabel();
 309         }
 310         return accessibleContext;
 311     }
 312 
 313     /**
 314      * This class implements accessibility support for the
 315      * <code>Label</code> class.  It provides an implementation of the
 316      * Java Accessibility API appropriate to label user-interface elements.
 317      * @since 1.3
 318      */
 319     protected class AccessibleAWTLabel extends AccessibleAWTComponent
 320     {
 321         /*
 322          * JDK 1.3 serialVersionUID
 323          */
 324         private static final long serialVersionUID = -3568967560160480438L;
 325 
 326         /**
 327          * Constructor for the accessible label.
 328          */
 329         public AccessibleAWTLabel() {
 330             super();
 331         }
 332 
 333         /**
 334          * Get the accessible name of this object.
 335          *
 336          * @return the localized name of the object -- can be null if this
 337          * object does not have a name
 338          * @see AccessibleContext#setAccessibleName
 339          */
 340         public String getAccessibleName() {
 341             if (accessibleName != null) {
 342                 return accessibleName;
 343             } else {
 344                 if (getText() == null) {
 345                     return super.getAccessibleName();
 346                 } else {
 347                     return getText();
 348                 }