action.html
来自「API資料大全」· HTML 代码 · 共 547 行 · 第 1/2 页
HTML
547 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:38:04 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface Action</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Action.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> PREV CLASS <A HREF="../../javax/swing/BoundedRangeModel.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Action.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.swing</FONT><BR>Interface Action</H2><DL><DT><B>All Superinterfaces:</B> <DD><A HREF="../../java/awt/event/ActionListener.html">ActionListener</A>, <A HREF="../../java/util/EventListener.html">EventListener</A></DD></DL><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../javax/swing/AbstractAction.html">AbstractAction</A></DD></DL><HR><DL><DT>public interface <B>Action</B><DT>extends <A HREF="../../java/awt/event/ActionListener.html">ActionListener</A></DL><P>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> Certain containers, including menus and tool bars, know how to add an <code>Action</code> object. When an <code>Action</code> object is added to such a container, the container: <ol type="a"> <li>Creates a component that is appropriate for that container (a tool bar creates a button component, for example). <li>Gets the appropriate property(s) from the <code>Action</code> object to customize the component (for example, the icon image and flyover text). <li>Checks the intial state of the <code>Action</code> object to determine if it is enabled or disabled, and renders the component in the appropriate fashion. <li>Registers a listener with the <code>Action</code> object so that is notified of state changes. When the <code>Action</code> object changes from enabled to disabled, or back, the container makes the appropriate revisions to the event-generation mechanisms and renders the component accordingly. </ol> For example, both a menu item and a toolbar button could access a <code>Cut</code> action object. The text associated with the object is specified as "Cut", and an image depicting a pair of scissors is specified as its icon. The <code>Cut</code> action-object can then be added to a menu and to a tool bar. Each container does the appropriate things with the object, and invokes its <code>actionPerformed</code> method when the component associated with it is activated. The application can then disable or enable the application object without worrying about what user-interface components are connected to it. <p> This interface can be added to an existing class or used to create an adapter (typically, by subclassing <code>AbstractActio</code>). The <code>Action</code> object can then be added to multiple action-aware containers and connected to Action-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 th is reason, you should take care to only use <code>Action</code>s where their benefits are desired, and use simple <code>ActionListeners</code> elsewhere.<P><DL><DT><B>See Also: </B><DD><A HREF="../../javax/swing/AbstractAction.html"><CODE>AbstractAction</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#ACCELERATOR_KEY">ACCELERATOR_KEY</A></B></CODE><BR> The key used for storing a <code>KeyStroke</code> to be used as the accelerator for the action.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#ACTION_COMMAND_KEY">ACTION_COMMAND_KEY</A></B></CODE><BR> The key used to determine the command string 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>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#DEFAULT">DEFAULT</A></B></CODE><BR> Useful constants that can be used as the storage-retrieval key when setting or getting one of this object's properties (text or icon).</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#LONG_DESCRIPTION">LONG_DESCRIPTION</A></B></CODE><BR> The key used for storing a longer description for the action, could be used for context-sensitive help.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#MNEMONIC_KEY">MNEMONIC_KEY</A></B></CODE><BR> The key used for storing an int key code to be used as the mnemonic for the action.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#NAME">NAME</A></B></CODE><BR> The key used for storing the name for the action, used for a menu or button.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#SHORT_DESCRIPTION">SHORT_DESCRIPTION</A></B></CODE><BR> The key used for storing a short description for the action, used for tooltip text.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#SMALL_ICON">SMALL_ICON</A></B></CODE><BR> The key used for storing a small icon for the action, used for toolbar buttons.</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#addPropertyChangeListener(java.beans.PropertyChangeListener)">addPropertyChangeListener</A></B>(<A HREF="../../java/beans/PropertyChangeListener.html">PropertyChangeListener</A> listener)</CODE><BR> Adds a <code>PropertyChange</code> listener.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#getValue(java.lang.String)">getValue</A></B>(<A HREF="../../java/lang/String.html">String</A> key)</CODE><BR> Gets one of this object's properties using the associated key.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#isEnabled()">isEnabled</A></B>()</CODE><BR> Returns the enabled state of the <code>Action</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/Action.html#putValue(java.lang.String, java.lang.Object)">putValue</A></B>(<A HREF="../../java/lang/String.html">String</A> key, <A HREF="../../java/lang/Object.html">Object</A> value)</CODE><BR> Sets one of this object's properties using the associated key.</TD>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?