src/java.desktop/share/classes/java/awt/Checkbox.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


 222         throws HeadlessException {
 223         this(label, state, group);
 224     }
 225 
 226     /**
 227      * Constructs a name for this component.  Called by
 228      * <code>getName</code> when the name is <code>null</code>.
 229      *
 230      * @return a name for this component
 231      */
 232     String constructComponentName() {
 233         synchronized (Checkbox.class) {
 234             return base + nameCounter++;
 235         }
 236     }
 237 
 238     /**
 239      * Creates the peer of the Checkbox. The peer allows you to change the
 240      * look of the Checkbox without changing its functionality.
 241      *
 242      * @see     java.awt.Toolkit#createCheckbox(java.awt.Checkbox)
 243      * @see     java.awt.Component#getToolkit()
 244      */
 245     public void addNotify() {
 246         synchronized (getTreeLock()) {
 247             if (peer == null)
 248                 peer = getToolkit().createCheckbox(this);
 249             super.addNotify();
 250         }
 251     }
 252 
 253     /**
 254      * Gets the label of this check box.
 255      *
 256      * @return   the label of this check box, or <code>null</code>
 257      *                  if this check box has no label.
 258      * @see      #setLabel(String)
 259      */
 260     public String getLabel() {
 261         return label;
 262     }
 263 
 264     /**
 265      * Sets this check box's label to be the string argument.
 266      *
 267      * @param    label   a string to set as the new label, or
 268      *                        <code>null</code> for no label.


   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


 222         throws HeadlessException {
 223         this(label, state, group);
 224     }
 225 
 226     /**
 227      * Constructs a name for this component.  Called by
 228      * <code>getName</code> when the name is <code>null</code>.
 229      *
 230      * @return a name for this component
 231      */
 232     String constructComponentName() {
 233         synchronized (Checkbox.class) {
 234             return base + nameCounter++;
 235         }
 236     }
 237 
 238     /**
 239      * Creates the peer of the Checkbox. The peer allows you to change the
 240      * look of the Checkbox without changing its functionality.
 241      *

 242      * @see     java.awt.Component#getToolkit()
 243      */
 244     public void addNotify() {
 245         synchronized (getTreeLock()) {
 246             if (peer == null)
 247                 peer = getComponentFactory().createCheckbox(this);
 248             super.addNotify();
 249         }
 250     }
 251 
 252     /**
 253      * Gets the label of this check box.
 254      *
 255      * @return   the label of this check box, or <code>null</code>
 256      *                  if this check box has no label.
 257      * @see      #setLabel(String)
 258      */
 259     public String getLabel() {
 260         return label;
 261     }
 262 
 263     /**
 264      * Sets this check box's label to be the string argument.
 265      *
 266      * @param    label   a string to set as the new label, or
 267      *                        <code>null</code> for no label.