src/share/classes/java/awt/Checkbox.java

Print this page


   1 /*
   2  * Copyright (c) 1995, 2013, 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


 696         if (accessibleContext == null) {
 697             accessibleContext = new AccessibleAWTCheckbox();
 698         }
 699         return accessibleContext;
 700     }
 701 
 702     /**
 703      * This class implements accessibility support for the
 704      * <code>Checkbox</code> class.  It provides an implementation of the
 705      * Java Accessibility API appropriate to checkbox user-interface elements.
 706      * @since 1.3
 707      */
 708     protected class AccessibleAWTCheckbox extends AccessibleAWTComponent
 709         implements ItemListener, AccessibleAction, AccessibleValue
 710     {
 711         /*
 712          * JDK 1.3 serialVersionUID
 713          */
 714         private static final long serialVersionUID = 7881579233144754107L;
 715 



 716         public AccessibleAWTCheckbox() {
 717             super();
 718             Checkbox.this.addItemListener(this);
 719         }
 720 
 721         /**
 722          * Fire accessible property change events when the state of the
 723          * toggle button changes.
 724          */
 725         public void itemStateChanged(ItemEvent e) {
 726             Checkbox cb = (Checkbox) e.getSource();
 727             if (Checkbox.this.accessibleContext != null) {
 728                 if (cb.getState()) {
 729                     Checkbox.this.accessibleContext.firePropertyChange(
 730                             AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
 731                             null, AccessibleState.CHECKED);
 732                 } else {
 733                     Checkbox.this.accessibleContext.firePropertyChange(
 734                             AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
 735                             AccessibleState.CHECKED, null);


   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


 696         if (accessibleContext == null) {
 697             accessibleContext = new AccessibleAWTCheckbox();
 698         }
 699         return accessibleContext;
 700     }
 701 
 702     /**
 703      * This class implements accessibility support for the
 704      * <code>Checkbox</code> class.  It provides an implementation of the
 705      * Java Accessibility API appropriate to checkbox user-interface elements.
 706      * @since 1.3
 707      */
 708     protected class AccessibleAWTCheckbox extends AccessibleAWTComponent
 709         implements ItemListener, AccessibleAction, AccessibleValue
 710     {
 711         /*
 712          * JDK 1.3 serialVersionUID
 713          */
 714         private static final long serialVersionUID = 7881579233144754107L;
 715 
 716         /**
 717          * Constructor for {@code AccessibleAWTCheckbox}
 718          */
 719         public AccessibleAWTCheckbox() {
 720             super();
 721             Checkbox.this.addItemListener(this);
 722         }
 723 
 724         /**
 725          * Fire accessible property change events when the state of the
 726          * toggle button changes.
 727          */
 728         public void itemStateChanged(ItemEvent e) {
 729             Checkbox cb = (Checkbox) e.getSource();
 730             if (Checkbox.this.accessibleContext != null) {
 731                 if (cb.getState()) {
 732                     Checkbox.this.accessibleContext.firePropertyChange(
 733                             AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
 734                             null, AccessibleState.CHECKED);
 735                 } else {
 736                     Checkbox.this.accessibleContext.firePropertyChange(
 737                             AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
 738                             AccessibleState.CHECKED, null);