开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
forked from Stefan/Java8Source
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (2)
master
develop
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (2)
master
develop
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (2)
master
develop
Java8Source
/
src
/
javax
/
swing
/
Action.java
Java8Source
/
src
/
javax
/
swing
/
Action.java
Action.java 16.37 KB
一键复制 编辑 原始数据 按行查看 历史
Stefan 提交于 2020年08月11日 23:17 +08:00 . 初始化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package javax.swing;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
/**
* The <code>Action</code> interface provides a useful extension to the
* <code>ActionListener</code>
* interface in cases where the same functionality may be accessed by
* several controls.
* <p>
* In addition to the <code>actionPerformed</code> method defined by the
* <code>ActionListener</code> interface, this interface allows the
* application to define, in a single place:
* <ul>
* <li>One or more text strings that describe the function. These strings
* can be used, for example, to display the flyover text for a button
* or to set the text in a menu item.
* <li>One or more icons that depict the function. These icons can be used
* for the images in a menu control, or for composite entries in a more
* sophisticated user interface.
* <li>The enabled/disabled state of the functionality. Instead of having
* to separately disable the menu item and the toolbar button, the
* application can disable the function that implements this interface.
* All components which are registered as listeners for the state change
* then know to disable event generation for that item and to modify the
* display accordingly.
* </ul>
* <p>
* This interface can be added to an existing class or used to create an
* adapter (typically, by subclassing <code>AbstractAction</code>).
* The <code>Action</code> object
* can then be added to multiple <code>Action</code>-aware containers
* and connected to <code>Action</code>-capable
* components. The GUI controls can then be activated or
* deactivated all at once by invoking the <code>Action</code> object's
* <code>setEnabled</code> method.
* <p>
* Note that <code>Action</code> implementations tend to be more expensive
* in terms of storage than a typical <code>ActionListener</code>,
* which does not offer the benefits of centralized control of
* functionality and broadcast of property changes. For this reason,
* you should take care to only use <code>Action</code>s where their benefits
* are desired, and use simple <code>ActionListener</code>s elsewhere.
* <br>
*
* <h3><a name="buttonActions"></a>Swing Components Supporting <code>Action</code></h3>
* <p>
* Many of Swing's components have an <code>Action</code> property. When
* an <code>Action</code> is set on a component, the following things
* happen:
* <ul>
* <li>The <code>Action</code> is added as an <code>ActionListener</code> to
* the component.
* <li>The component configures some of its properties to match the
* <code>Action</code>.
* <li>The component installs a <code>PropertyChangeListener</code> on the
* <code>Action</code> so that the component can change its properties
* to reflect changes in the <code>Action</code>'s properties.
* </ul>
* <p>
* The following table describes the properties used by
* <code>Swing</code> components that support <code>Actions</code>.
* In the table, <em>button</em> refers to any
* <code>AbstractButton</code> subclass, which includes not only
* <code>JButton</code> but also classes such as
* <code>JMenuItem</code>. Unless otherwise stated, a
* <code>null</code> property value in an <code>Action</code> (or a
* <code>Action</code> that is <code>null</code>) results in the
* button's corresponding property being set to <code>null</code>.
*
* <table border="1" cellpadding="1" cellspacing="0"
* summary="Supported Action properties">
* <tr valign="top" align="left">
* <th style="background-color:#CCCCFF" align="left">Component Property
* <th style="background-color:#CCCCFF" align="left">Components
* <th style="background-color:#CCCCFF" align="left">Action Key
* <th style="background-color:#CCCCFF" align="left">Notes
* <tr valign="top" align="left">
* <td><b><code>enabled</code></b>
* <td>All
* <td>The <code>isEnabled</code> method
* <td>&nbsp;
* <tr valign="top" align="left">
* <td><b><code>toolTipText</code></b>
* <td>All
* <td><code>SHORT_DESCRIPTION</code>
* <td>&nbsp;
* <tr valign="top" align="left">
* <td><b><code>actionCommand</code></b>
* <td>All
* <td><code>ACTION_COMMAND_KEY</code>
* <td>&nbsp;
* <tr valign="top" align="left">
* <td><b><code>mnemonic</code></b>
* <td>All buttons
* <td><code>MNEMONIC_KEY</code>
* <td>A <code>null</code> value or <code>Action</code> results in the
* button's <code>mnemonic</code> property being set to
* <code>'0円'</code>.
* <tr valign="top" align="left">
* <td><b><code>text</code></b>
* <td>All buttons
* <td><code>NAME</code>
* <td>If you do not want the text of the button to mirror that
* of the <code>Action</code>, set the property
* <code>hideActionText</code> to <code>true</code>. If
* <code>hideActionText</code> is <code>true</code>, setting the
* <code>Action</code> changes the text of the button to
* <code>null</code> and any changes to <code>NAME</code>
* are ignored. <code>hideActionText</code> is useful for
* tool bar buttons that typically only show an <code>Icon</code>.
* <code>JToolBar.add(Action)</code> sets the property to
* <code>true</code> if the <code>Action</code> has a
* non-<code>null</code> value for <code>LARGE_ICON_KEY</code> or
* <code>SMALL_ICON</code>.
* <tr valign="top" align="left">
* <td><b><code>displayedMnemonicIndex</code></b>
* <td>All buttons
* <td><code>DISPLAYED_MNEMONIC_INDEX_KEY</code>
* <td>If the value of <code>DISPLAYED_MNEMONIC_INDEX_KEY</code> is
* beyond the bounds of the text, it is ignored. When
* <code>setAction</code> is called, if the value from the
* <code>Action</code> is <code>null</code>, the displayed
* mnemonic index is not updated. In any subsequent changes to
* <code>DISPLAYED_MNEMONIC_INDEX_KEY</code>, <code>null</code>
* is treated as -1.
* <tr valign="top" align="left">
* <td><b><code>icon</code></b>
* <td>All buttons except of <code>JCheckBox</code>,
* <code>JToggleButton</code> and <code>JRadioButton</code>.
* <td>either <code>LARGE_ICON_KEY</code> or
* <code>SMALL_ICON</code>
* <td>The <code>JMenuItem</code> subclasses only use
* <code>SMALL_ICON</code>. All other buttons will use
* <code>LARGE_ICON_KEY</code>; if the value is <code>null</code> they
* use <code>SMALL_ICON</code>.
* <tr valign="top" align="left">
* <td><b><code>accelerator</code></b>
* <td>All <code>JMenuItem</code> subclasses, with the exception of
* <code>JMenu</code>.
* <td><code>ACCELERATOR_KEY</code>
* <td>&nbsp;
* <tr valign="top" align="left">
* <td><b><code>selected</code></b>
* <td><code>JToggleButton</code>, <code>JCheckBox</code>,
* <code>JRadioButton</code>, <code>JCheckBoxMenuItem</code> and
* <code>JRadioButtonMenuItem</code>
* <td><code>SELECTED_KEY</code>
* <td>Components that honor this property only use
* the value if it is {@code non-null}. For example, if
* you set an {@code Action} that has a {@code null}
* value for {@code SELECTED_KEY} on a {@code JToggleButton}, the
* {@code JToggleButton} will not update it's selected state in
* any way. Similarly, any time the {@code JToggleButton}'s
* selected state changes it will only set the value back on
* the {@code Action} if the {@code Action} has a {@code non-null}
* value for {@code SELECTED_KEY}.
* <br>
* Components that honor this property keep their selected state
* in sync with this property. When the same {@code Action} is used
* with multiple components, all the components keep their selected
* state in sync with this property. Mutually exclusive
* buttons, such as {@code JToggleButton}s in a {@code ButtonGroup},
* force only one of the buttons to be selected. As such, do not
* use the same {@code Action} that defines a value for the
* {@code SELECTED_KEY} property with multiple mutually
* exclusive buttons.
* </table>
* <p>
* <code>JPopupMenu</code>, <code>JToolBar</code> and <code>JMenu</code>
* all provide convenience methods for creating a component and setting the
* <code>Action</code> on the corresponding component. Refer to each of
* these classes for more information.
* <p>
* <code>Action</code> uses <code>PropertyChangeListener</code> to
* inform listeners the <code>Action</code> has changed. The beans
* specification indicates that a <code>null</code> property name can
* be used to indicate multiple values have changed. By default Swing
* components that take an <code>Action</code> do not handle such a
* change. To indicate that Swing should treat <code>null</code>
* according to the beans specification set the system property
* <code>swing.actions.reconfigureOnNull</code> to the <code>String</code>
* value <code>true</code>.
*
* @author Georges Saab
* @see AbstractAction
*/
public interface Action extends ActionListener {
/**
* Useful constants that can be used as the storage-retrieval key
* when setting or getting one of this object's properties (text
* or icon).
*/
/**
* Not currently used.
*/
public static final String DEFAULT = "Default";
/**
* The key used for storing the <code>String</code> name
* for the action, used for a menu or button.
*/
public static final String NAME = "Name";
/**
* The key used for storing a short <code>String</code>
* description for the action, used for tooltip text.
*/
public static final String SHORT_DESCRIPTION = "ShortDescription";
/**
* The key used for storing a longer <code>String</code>
* description for the action, could be used for context-sensitive help.
*/
public static final String LONG_DESCRIPTION = "LongDescription";
/**
* The key used for storing a small <code>Icon</code>, such
* as <code>ImageIcon</code>. This is typically used with
* menus such as <code>JMenuItem</code>.
* <p>
* If the same <code>Action</code> is used with menus and buttons you'll
* typically specify both a <code>SMALL_ICON</code> and a
* <code>LARGE_ICON_KEY</code>. The menu will use the
* <code>SMALL_ICON</code> and the button will use the
* <code>LARGE_ICON_KEY</code>.
*/
public static final String SMALL_ICON = "SmallIcon";
/**
* The key used to determine the command <code>String</code> for the
* <code>ActionEvent</code> that will be created when an
* <code>Action</code> is going to be notified as the result of
* residing in a <code>Keymap</code> associated with a
* <code>JComponent</code>.
*/
public static final String ACTION_COMMAND_KEY = "ActionCommandKey";
/**
* The key used for storing a <code>KeyStroke</code> to be used as the
* accelerator for the action.
*
* @since 1.3
*/
public static final String ACCELERATOR_KEY="AcceleratorKey";
/**
* The key used for storing an <code>Integer</code> that corresponds to
* one of the <code>KeyEvent</code> key codes. The value is
* commonly used to specify a mnemonic. For example:
* <code>myAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_A)</code>
* sets the mnemonic of <code>myAction</code> to 'a', while
* <code>myAction.putValue(Action.MNEMONIC_KEY, KeyEvent.getExtendedKeyCodeForChar('\u0444'))</code>
* sets the mnemonic of <code>myAction</code> to Cyrillic letter "Ef".
*
* @since 1.3
*/
public static final String MNEMONIC_KEY="MnemonicKey";
/**
* The key used for storing a <code>Boolean</code> that corresponds
* to the selected state. This is typically used only for components
* that have a meaningful selection state. For example,
* <code>JRadioButton</code> and <code>JCheckBox</code> make use of
* this but instances of <code>JMenu</code> don't.
* <p>
* This property differs from the others in that it is both read
* by the component and set by the component. For example,
* if an <code>Action</code> is attached to a <code>JCheckBox</code>
* the selected state of the <code>JCheckBox</code> will be set from
* that of the <code>Action</code>. If the user clicks on the
* <code>JCheckBox</code> the selected state of the <code>JCheckBox</code>
* <b>and</b> the <code>Action</code> will <b>both</b> be updated.
* <p>
* Note: the value of this field is prefixed with 'Swing' to
* avoid possible collisions with existing <code>Actions</code>.
*
* @since 1.6
*/
public static final String SELECTED_KEY = "SwingSelectedKey";
/**
* The key used for storing an <code>Integer</code> that corresponds
* to the index in the text (identified by the <code>NAME</code>
* property) that the decoration for a mnemonic should be rendered at. If
* the value of this property is greater than or equal to the length of
* the text, it will treated as -1.
* <p>
* Note: the value of this field is prefixed with 'Swing' to
* avoid possible collisions with existing <code>Actions</code>.
*
* @see AbstractButton#setDisplayedMnemonicIndex
* @since 1.6
*/
public static final String DISPLAYED_MNEMONIC_INDEX_KEY =
"SwingDisplayedMnemonicIndexKey";
/**
* The key used for storing an <code>Icon</code>. This is typically
* used by buttons, such as <code>JButton</code> and
* <code>JToggleButton</code>.
* <p>
* If the same <code>Action</code> is used with menus and buttons you'll
* typically specify both a <code>SMALL_ICON</code> and a
* <code>LARGE_ICON_KEY</code>. The menu will use the
* <code>SMALL_ICON</code> and the button the <code>LARGE_ICON_KEY</code>.
* <p>
* Note: the value of this field is prefixed with 'Swing' to
* avoid possible collisions with existing <code>Actions</code>.
*
* @since 1.6
*/
public static final String LARGE_ICON_KEY = "SwingLargeIconKey";
/**
* Gets one of this object's properties
* using the associated key.
* @see #putValue
*/
public Object getValue(String key);
/**
* Sets one of this object's properties
* using the associated key. If the value has
* changed, a <code>PropertyChangeEvent</code> is sent
* to listeners.
*
* @param key a <code>String</code> containing the key
* @param value an <code>Object</code> value
*/
public void putValue(String key, Object value);
/**
* Sets the enabled state of the <code>Action</code>. When enabled,
* any component associated with this object is active and
* able to fire this object's <code>actionPerformed</code> method.
* If the value has changed, a <code>PropertyChangeEvent</code> is sent
* to listeners.
*
* @param b true to enable this <code>Action</code>, false to disable it
*/
public void setEnabled(boolean b);
/**
* Returns the enabled state of the <code>Action</code>. When enabled,
* any component associated with this object is active and
* able to fire this object's <code>actionPerformed</code> method.
*
* @return true if this <code>Action</code> is enabled
*/
public boolean isEnabled();
/**
* Adds a <code>PropertyChange</code> listener. Containers and attached
* components use these methods to register interest in this
* <code>Action</code> object. When its enabled state or other property
* changes, the registered listeners are informed of the change.
*
* @param listener a <code>PropertyChangeListener</code> object
*/
public void addPropertyChangeListener(PropertyChangeListener listener);
/**
* Removes a <code>PropertyChange</code> listener.
*
* @param listener a <code>PropertyChangeListener</code> object
* @see #addPropertyChangeListener
*/
public void removePropertyChangeListener(PropertyChangeListener listener);
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/yxljava/Java8Source.git
git@gitee.com:yxljava/Java8Source.git
yxljava
Java8Source
Java8Source
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /