jdk/src/share/classes/java/awt/Button.java

Print this page




   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
  23  * questions.
  24  */
  25 
  26 package java.awt;
  27 
  28 import java.awt.peer.ButtonPeer;

  29 import java.util.EventListener;
  30 import java.awt.event.*;
  31 import java.io.ObjectOutputStream;
  32 import java.io.ObjectInputStream;
  33 import java.io.IOException;
  34 import javax.accessibility.*;
  35 
  36 /**
  37  * This class creates a labeled button. The application can cause
  38  * some action to happen when the button is pushed. This image
  39  * depicts three views of a "<code>Quit</code>" button as it appears
  40  * under the Solaris operating system:
  41  * <p>
  42  * <img src="doc-files/Button-1.gif" alt="The following context describes the graphic"
  43  * style="float:center; margin: 7px 10px;">
  44  * <p>
  45  * The first view shows the button as it appears normally.
  46  * The second view shows the button
  47  * when it has input focus. Its outline is darkened to let the
  48  * user know that it is an active object. The third view shows the


 495         else // skip value for unrecognized key
 496           s.readObject();
 497       }
 498     }
 499 
 500 
 501 /////////////////
 502 // Accessibility support
 503 ////////////////
 504 
 505     /**
 506      * Gets the <code>AccessibleContext</code> associated with
 507      * this <code>Button</code>. For buttons, the
 508      * <code>AccessibleContext</code> takes the form of an
 509      * <code>AccessibleAWTButton</code>.
 510      * A new <code>AccessibleAWTButton</code> instance is
 511      * created if necessary.
 512      *
 513      * @return an <code>AccessibleAWTButton</code> that serves as the
 514      *         <code>AccessibleContext</code> of this <code>Button</code>
 515      * @beaninfo
 516      *       expert: true
 517      *  description: The AccessibleContext associated with this Button.
 518      * @since 1.3
 519      */


 520     public AccessibleContext getAccessibleContext() {
 521         if (accessibleContext == null) {
 522             accessibleContext = new AccessibleAWTButton();
 523         }
 524         return accessibleContext;
 525     }
 526 
 527     /**
 528      * This class implements accessibility support for the
 529      * <code>Button</code> class.  It provides an implementation of the
 530      * Java Accessibility API appropriate to button user-interface elements.
 531      * @since 1.3
 532      */
 533     protected class AccessibleAWTButton extends AccessibleAWTComponent
 534         implements AccessibleAction, AccessibleValue
 535     {
 536         /*
 537          * JDK 1.3 serialVersionUID
 538          */
 539         private static final long serialVersionUID = -5932203980244017102L;




   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
  23  * questions.
  24  */
  25 
  26 package java.awt;
  27 
  28 import java.awt.peer.ButtonPeer;
  29 import java.beans.BeanProperty;
  30 import java.util.EventListener;
  31 import java.awt.event.*;
  32 import java.io.ObjectOutputStream;
  33 import java.io.ObjectInputStream;
  34 import java.io.IOException;
  35 import javax.accessibility.*;
  36 
  37 /**
  38  * This class creates a labeled button. The application can cause
  39  * some action to happen when the button is pushed. This image
  40  * depicts three views of a "<code>Quit</code>" button as it appears
  41  * under the Solaris operating system:
  42  * <p>
  43  * <img src="doc-files/Button-1.gif" alt="The following context describes the graphic"
  44  * style="float:center; margin: 7px 10px;">
  45  * <p>
  46  * The first view shows the button as it appears normally.
  47  * The second view shows the button
  48  * when it has input focus. Its outline is darkened to let the
  49  * user know that it is an active object. The third view shows the


 496         else // skip value for unrecognized key
 497           s.readObject();
 498       }
 499     }
 500 
 501 
 502 /////////////////
 503 // Accessibility support
 504 ////////////////
 505 
 506     /**
 507      * Gets the <code>AccessibleContext</code> associated with
 508      * this <code>Button</code>. For buttons, the
 509      * <code>AccessibleContext</code> takes the form of an
 510      * <code>AccessibleAWTButton</code>.
 511      * A new <code>AccessibleAWTButton</code> instance is
 512      * created if necessary.
 513      *
 514      * @return an <code>AccessibleAWTButton</code> that serves as the
 515      *         <code>AccessibleContext</code> of this <code>Button</code>



 516      * @since 1.3
 517      */
 518     @BeanProperty(expert = true, description
 519             = "The AccessibleContext associated with this Button.")
 520     public AccessibleContext getAccessibleContext() {
 521         if (accessibleContext == null) {
 522             accessibleContext = new AccessibleAWTButton();
 523         }
 524         return accessibleContext;
 525     }
 526 
 527     /**
 528      * This class implements accessibility support for the
 529      * <code>Button</code> class.  It provides an implementation of the
 530      * Java Accessibility API appropriate to button user-interface elements.
 531      * @since 1.3
 532      */
 533     protected class AccessibleAWTButton extends AccessibleAWTComponent
 534         implements AccessibleAction, AccessibleValue
 535     {
 536         /*
 537          * JDK 1.3 serialVersionUID
 538          */
 539         private static final long serialVersionUID = -5932203980244017102L;