< prev index next >

src/java.desktop/share/classes/javax/swing/Action.java

Print this page




  77  * <ul>
  78  * <li>The <code>Action</code> is added as an <code>ActionListener</code> to
  79  *     the component.
  80  * <li>The component configures some of its properties to match the
  81  *      <code>Action</code>.
  82  * <li>The component installs a <code>PropertyChangeListener</code> on the
  83  *     <code>Action</code> so that the component can change its properties
  84  *     to reflect changes in the <code>Action</code>'s properties.
  85  * </ul>
  86  * <p>
  87  * The following table describes the properties used by
  88  * <code>Swing</code> components that support <code>Actions</code>.
  89  * In the table, <em>button</em> refers to any
  90  * <code>AbstractButton</code> subclass, which includes not only
  91  * <code>JButton</code> but also classes such as
  92  * <code>JMenuItem</code>. Unless otherwise stated, a
  93  * <code>null</code> property value in an <code>Action</code> (or a
  94  * <code>Action</code> that is <code>null</code>) results in the
  95  * button's corresponding property being set to <code>null</code>.
  96  *
  97  * <table border="1" cellpadding="1" cellspacing="0"
  98  *         summary="Supported Action properties">
  99  *  <tr valign="top" style="text-align:left">
 100  *    <th style="background-color:#CCCCFF;text-align:left">Component Property
 101  *    <th style="background-color:#CCCCFF;text-align:left">Components
 102  *    <th style="background-color:#CCCCFF;text-align:left">Action Key
 103  *    <th style="background-color:#CCCCFF;text-align:left">Notes



 104  *  <tr valign="top" style="text-align:left">
 105  *      <td><b><code>enabled</code></b>
 106  *      <td>All
 107  *      <td>The <code>isEnabled</code> method
 108  *      <td>&nbsp;
 109  *  <tr valign="top" style="text-align:left">
 110  *      <td><b><code>toolTipText</code></b>
 111  *      <td>All
 112  *      <td><code>SHORT_DESCRIPTION</code>
 113  *      <td>&nbsp;
 114  *  <tr valign="top" style="text-align:left">
 115  *      <td><b><code>actionCommand</code></b>
 116  *      <td>All
 117  *      <td><code>ACTION_COMMAND_KEY</code>
 118  *      <td>&nbsp;
 119  *  <tr valign="top" style="text-align:left">
 120  *      <td><b><code>mnemonic</code></b>
 121  *      <td>All buttons
 122  *      <td><code>MNEMONIC_KEY</code>
 123  *      <td>A <code>null</code> value or <code>Action</code> results in the


 174  *      <td><code>SELECTED_KEY</code>
 175  *      <td>Components that honor this property only use
 176  *          the value if it is {@code non-null}. For example, if
 177  *          you set an {@code Action} that has a {@code null}
 178  *          value for {@code SELECTED_KEY} on a {@code JToggleButton}, the
 179  *          {@code JToggleButton} will not update it's selected state in
 180  *          any way. Similarly, any time the {@code JToggleButton}'s
 181  *          selected state changes it will only set the value back on
 182  *          the {@code Action} if the {@code Action} has a {@code non-null}
 183  *          value for {@code SELECTED_KEY}.
 184  *          <br>
 185  *          Components that honor this property keep their selected state
 186  *          in sync with this property. When the same {@code Action} is used
 187  *          with multiple components, all the components keep their selected
 188  *          state in sync with this property. Mutually exclusive
 189  *          buttons, such as {@code JToggleButton}s in a {@code ButtonGroup},
 190  *          force only one of the buttons to be selected. As such, do not
 191  *          use the same {@code Action} that defines a value for the
 192  *          {@code SELECTED_KEY} property with multiple mutually
 193  *          exclusive buttons.

 194  * </table>
 195  * <p>
 196  * <code>JPopupMenu</code>, <code>JToolBar</code> and <code>JMenu</code>
 197  * all provide convenience methods for creating a component and setting the
 198  * <code>Action</code> on the corresponding component.  Refer to each of
 199  * these classes for more information.
 200  * <p>
 201  * <code>Action</code> uses <code>PropertyChangeListener</code> to
 202  * inform listeners the <code>Action</code> has changed.  The beans
 203  * specification indicates that a <code>null</code> property name can
 204  * be used to indicate multiple values have changed.  By default Swing
 205  * components that take an <code>Action</code> do not handle such a
 206  * change.  To indicate that Swing should treat <code>null</code>
 207  * according to the beans specification set the system property
 208  * <code>swing.actions.reconfigureOnNull</code> to the <code>String</code>
 209  * value <code>true</code>.
 210  *
 211  * @author Georges Saab
 212  * @see AbstractAction
 213  * @since 1.2




  77  * <ul>
  78  * <li>The <code>Action</code> is added as an <code>ActionListener</code> to
  79  *     the component.
  80  * <li>The component configures some of its properties to match the
  81  *      <code>Action</code>.
  82  * <li>The component installs a <code>PropertyChangeListener</code> on the
  83  *     <code>Action</code> so that the component can change its properties
  84  *     to reflect changes in the <code>Action</code>'s properties.
  85  * </ul>
  86  * <p>
  87  * The following table describes the properties used by
  88  * <code>Swing</code> components that support <code>Actions</code>.
  89  * In the table, <em>button</em> refers to any
  90  * <code>AbstractButton</code> subclass, which includes not only
  91  * <code>JButton</code> but also classes such as
  92  * <code>JMenuItem</code>. Unless otherwise stated, a
  93  * <code>null</code> property value in an <code>Action</code> (or a
  94  * <code>Action</code> that is <code>null</code>) results in the
  95  * button's corresponding property being set to <code>null</code>.
  96  *
  97  * <table class="striped">
  98  * <caption style="display:none">Supported Action properties</caption>
  99  * <thead>
 100  *  <tr>
 101  *    <th>Component Property
 102  *    <th>Components
 103  *    <th>Action Key
 104  *    <th>Notes
 105  * </thead>
 106  * <tbody>
 107  *  <tr valign="top" style="text-align:left">
 108  *      <td><b><code>enabled</code></b>
 109  *      <td>All
 110  *      <td>The <code>isEnabled</code> method
 111  *      <td>&nbsp;
 112  *  <tr valign="top" style="text-align:left">
 113  *      <td><b><code>toolTipText</code></b>
 114  *      <td>All
 115  *      <td><code>SHORT_DESCRIPTION</code>
 116  *      <td>&nbsp;
 117  *  <tr valign="top" style="text-align:left">
 118  *      <td><b><code>actionCommand</code></b>
 119  *      <td>All
 120  *      <td><code>ACTION_COMMAND_KEY</code>
 121  *      <td>&nbsp;
 122  *  <tr valign="top" style="text-align:left">
 123  *      <td><b><code>mnemonic</code></b>
 124  *      <td>All buttons
 125  *      <td><code>MNEMONIC_KEY</code>
 126  *      <td>A <code>null</code> value or <code>Action</code> results in the


 177  *      <td><code>SELECTED_KEY</code>
 178  *      <td>Components that honor this property only use
 179  *          the value if it is {@code non-null}. For example, if
 180  *          you set an {@code Action} that has a {@code null}
 181  *          value for {@code SELECTED_KEY} on a {@code JToggleButton}, the
 182  *          {@code JToggleButton} will not update it's selected state in
 183  *          any way. Similarly, any time the {@code JToggleButton}'s
 184  *          selected state changes it will only set the value back on
 185  *          the {@code Action} if the {@code Action} has a {@code non-null}
 186  *          value for {@code SELECTED_KEY}.
 187  *          <br>
 188  *          Components that honor this property keep their selected state
 189  *          in sync with this property. When the same {@code Action} is used
 190  *          with multiple components, all the components keep their selected
 191  *          state in sync with this property. Mutually exclusive
 192  *          buttons, such as {@code JToggleButton}s in a {@code ButtonGroup},
 193  *          force only one of the buttons to be selected. As such, do not
 194  *          use the same {@code Action} that defines a value for the
 195  *          {@code SELECTED_KEY} property with multiple mutually
 196  *          exclusive buttons.
 197  * </tbody>
 198  * </table>
 199  * <p>
 200  * <code>JPopupMenu</code>, <code>JToolBar</code> and <code>JMenu</code>
 201  * all provide convenience methods for creating a component and setting the
 202  * <code>Action</code> on the corresponding component.  Refer to each of
 203  * these classes for more information.
 204  * <p>
 205  * <code>Action</code> uses <code>PropertyChangeListener</code> to
 206  * inform listeners the <code>Action</code> has changed.  The beans
 207  * specification indicates that a <code>null</code> property name can
 208  * be used to indicate multiple values have changed.  By default Swing
 209  * components that take an <code>Action</code> do not handle such a
 210  * change.  To indicate that Swing should treat <code>null</code>
 211  * according to the beans specification set the system property
 212  * <code>swing.actions.reconfigureOnNull</code> to the <code>String</code>
 213  * value <code>true</code>.
 214  *
 215  * @author Georges Saab
 216  * @see AbstractAction
 217  * @since 1.2


< prev index next >