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

Print this page


   1 /*
   2  * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 167     }
 168 
 169     /**
 170      * Construct a name for this component.  Called by getName() when the
 171      * name is <code>null</code>.
 172      */
 173     String constructComponentName() {
 174         synchronized (Label.class) {
 175             return base + nameCounter++;
 176         }
 177     }
 178 
 179     /**
 180      * Creates the peer for this label.  The peer allows us to
 181      * modify the appearance of the label without changing its
 182      * functionality.
 183      */
 184     public void addNotify() {
 185         synchronized (getTreeLock()) {
 186             if (peer == null)
 187                 peer = getToolkit().createLabel(this);
 188             super.addNotify();
 189         }
 190     }
 191 
 192     /**
 193      * Gets the current alignment of this label. Possible values are
 194      * <code>Label.LEFT</code>, <code>Label.RIGHT</code>, and
 195      * <code>Label.CENTER</code>.
 196      * @return the alignment of this label
 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.


   1 /*
   2  * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 167     }
 168 
 169     /**
 170      * Construct a name for this component.  Called by getName() when the
 171      * name is <code>null</code>.
 172      */
 173     String constructComponentName() {
 174         synchronized (Label.class) {
 175             return base + nameCounter++;
 176         }
 177     }
 178 
 179     /**
 180      * Creates the peer for this label.  The peer allows us to
 181      * modify the appearance of the label without changing its
 182      * functionality.
 183      */
 184     public void addNotify() {
 185         synchronized (getTreeLock()) {
 186             if (peer == null)
 187                 peer = getComponentFactory().createLabel(this);
 188             super.addNotify();
 189         }
 190     }
 191 
 192     /**
 193      * Gets the current alignment of this label. Possible values are
 194      * <code>Label.LEFT</code>, <code>Label.RIGHT</code>, and
 195      * <code>Label.CENTER</code>.
 196      * @return the alignment of this label
 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.