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


 221     /**
 222      * Sets the command name for the action event fired
 223      * by this button. By default this action command is
 224      * set to match the label of the button.
 225      *
 226      * @param     command  a string used to set the button's
 227      *                  action command.
 228      *            If the string is <code>null</code> then the action command
 229      *            is set to match the label of the button.
 230      * @see       java.awt.event.ActionEvent
 231      * @since     JDK1.1
 232      */
 233     public void setActionCommand(String command) {
 234         actionCommand = command;
 235     }
 236 
 237     /**
 238      * Returns the command name of the action event fired by this button.
 239      * If the command name is <code>null</code> (default) then this method
 240      * returns the label of the button.


 241      */
 242     public String getActionCommand() {
 243         return (actionCommand == null? label : actionCommand);
 244     }
 245 
 246     /**
 247      * Adds the specified action listener to receive action events from
 248      * this button. Action events occur when a user presses or releases
 249      * the mouse over this button.
 250      * If l is null, no exception is thrown and no action is performed.
 251      * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
 252      * >AWT Threading Issues</a> for details on AWT's threading model.
 253      *
 254      * @param         l the action listener
 255      * @see           #removeActionListener
 256      * @see           #getActionListeners
 257      * @see           java.awt.event.ActionListener
 258      * @since         JDK1.1
 259      */
 260     public synchronized void addActionListener(ActionListener l) {


   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


 221     /**
 222      * Sets the command name for the action event fired
 223      * by this button. By default this action command is
 224      * set to match the label of the button.
 225      *
 226      * @param     command  a string used to set the button's
 227      *                  action command.
 228      *            If the string is <code>null</code> then the action command
 229      *            is set to match the label of the button.
 230      * @see       java.awt.event.ActionEvent
 231      * @since     JDK1.1
 232      */
 233     public void setActionCommand(String command) {
 234         actionCommand = command;
 235     }
 236 
 237     /**
 238      * Returns the command name of the action event fired by this button.
 239      * If the command name is <code>null</code> (default) then this method
 240      * returns the label of the button.
 241      *
 242      * @return the action command name (or label) for this button
 243      */
 244     public String getActionCommand() {
 245         return (actionCommand == null? label : actionCommand);
 246     }
 247 
 248     /**
 249      * Adds the specified action listener to receive action events from
 250      * this button. Action events occur when a user presses or releases
 251      * the mouse over this button.
 252      * If l is null, no exception is thrown and no action is performed.
 253      * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
 254      * >AWT Threading Issues</a> for details on AWT's threading model.
 255      *
 256      * @param         l the action listener
 257      * @see           #removeActionListener
 258      * @see           #getActionListeners
 259      * @see           java.awt.event.ActionListener
 260      * @since         JDK1.1
 261      */
 262     public synchronized void addActionListener(ActionListener l) {