📄 buttonmodel.html
字号:
<!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:05 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface ButtonModel</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/ButtonModel.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"> <A HREF="../../javax/swing/BoundedRangeModel.html"><B>PREV CLASS</B></A> <A HREF="../../javax/swing/CellEditor.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="ButtonModel.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | 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 ButtonModel</H2><DL><DT><B>All Superinterfaces:</B> <DD><A HREF="../../java/awt/ItemSelectable.html">ItemSelectable</A></DD></DL><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../javax/swing/DefaultButtonModel.html">DefaultButtonModel</A></DD></DL><HR><DL><DT>public interface <B>ButtonModel</B><DT>extends <A HREF="../../java/awt/ItemSelectable.html">ItemSelectable</A></DL><P>State Model for buttons. This model is used for check boxes and radio buttons, which are special kinds of buttons, as well as for normal buttons. For check boxes and radio buttons, pressing the mouse selects the button. For normal buttons, pressing the mouse "arms" the button. Releasing the mouse over the button then initiates a <i>button</i> press, firing its action event. Releasing the mouse elsewhere disarms the button. <p> In use, a UI will invoke <A HREF="../../javax/swing/ButtonModel.html#setSelected(boolean)"><CODE>setSelected(boolean)</CODE></A> when a mouse click occurs over a check box or radio button. It will invoke <A HREF="../../javax/swing/ButtonModel.html#setArmed(boolean)"><CODE>setArmed(boolean)</CODE></A> when the mouse is pressed over a regular button and invoke <A HREF="../../javax/swing/ButtonModel.html#setPressed(boolean)"><CODE>setPressed(boolean)</CODE></A> when the mouse is released. If the mouse travels outside the button in the meantime, <code>setArmed(false)</code> will tell the button not to fire when it sees <code>setPressed</code>. (If the mouse travels back in, the button will be rearmed.) <blockquote> <b>Note: </b><br> A button is triggered when it is both "armed" and "pressed". </blockquote><P><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== 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/ButtonModel.html#addActionListener(java.awt.event.ActionListener)">addActionListener</A></B>(<A HREF="../../java/awt/event/ActionListener.html">ActionListener</A> l)</CODE><BR> Adds an ActionListener to the button.</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/ButtonModel.html#addChangeListener(javax.swing.event.ChangeListener)">addChangeListener</A></B>(<A HREF="../../javax/swing/event/ChangeListener.html">ChangeListener</A> l)</CODE><BR> Adds a ChangeListener to the button.</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/ButtonModel.html#addItemListener(java.awt.event.ItemListener)">addItemListener</A></B>(<A HREF="../../java/awt/event/ItemListener.html">ItemListener</A> l)</CODE><BR> Adds an ItemListener to the button.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/ButtonModel.html#getActionCommand()">getActionCommand</A></B>()</CODE><BR> Returns the action command for this button.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/swing/ButtonModel.html#getMnemonic()">getMnemonic</A></B>()</CODE><BR> Gets the keyboard mnemonic for this model</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/ButtonModel.html#isArmed()">isArmed</A></B>()</CODE><BR> Indicates partial commitment towards pressing the button.</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/ButtonModel.html#isEnabled()">isEnabled</A></B>()</CODE><BR> Indicates if the button can be selected or pressed by an input device (such as a mouse pointer).</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/ButtonModel.html#isPressed()">isPressed</A></B>()</CODE><BR> Indicates if button has been pressed.</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/ButtonModel.html#isRollover()">isRollover</A></B>()</CODE><BR> Indicates that the mouse is over the button.</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/ButtonModel.html#isSelected()">isSelected</A></B>()</CODE><BR> Indicates if the button has been selected.</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/ButtonModel.html#removeActionListener(java.awt.event.ActionListener)">removeActionListener</A></B>(<A HREF="../../java/awt/event/ActionListener.html">ActionListener</A> l)</CODE><BR> Removes an ActionListener from the button.</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/ButtonModel.html#removeChangeListener(javax.swing.event.ChangeListener)">removeChangeListener</A></B>(<A HREF="../../javax/swing/event/ChangeListener.html">ChangeListener</A> l)</CODE><BR> Removes a ChangeListener from the button.</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/ButtonModel.html#removeItemListener(java.awt.event.ItemListener)">removeItemListener</A></B>(<A HREF="../../java/awt/event/ItemListener.html">ItemListener</A> l)</CODE><BR> Removes an ItemListener from the button.</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/ButtonModel.html#setActionCommand(java.lang.String)">setActionCommand</A></B>(<A HREF="../../java/lang/String.html">String</A> s)</CODE><BR> Sets the actionCommand string that gets sent as part of the event when the button is pressed.</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/ButtonModel.html#setArmed(boolean)">setArmed</A></B>(boolean b)</CODE><BR> Marks the button as "armed".</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/ButtonModel.html#setEnabled(boolean)">setEnabled</A></B>(boolean b)</CODE><BR> Enables or disables the button.</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/ButtonModel.html#setGroup(javax.swing.ButtonGroup)">setGroup</A></B>(<A HREF="../../javax/swing/ButtonGroup.html">ButtonGroup</A> group)</CODE><BR> Identifies the group this button belongs to -- needed for radio buttons, which are mutually exclusive within their group.</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/ButtonModel.html#setMnemonic(int)">setMnemonic</A></B>(int key)</CODE><BR> Sets the keyboard mnemonic (shortcut key or accelerator key) for this button.</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/ButtonModel.html#setPressed(boolean)">setPressed</A></B>(boolean b)</CODE><BR> Sets the button to pressed or unpressed.</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/ButtonModel.html#setRollover(boolean)">setRollover</A></B>(boolean b)</CODE><BR> Sets or clears the button's rollover state</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/ButtonModel.html#setSelected(boolean)">setSelected</A></B>(boolean b)</CODE><BR> Selects or deselects the button.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.awt.ItemSelectable"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from interface java.awt.<A HREF="../../java/awt/ItemSelectable.html">ItemSelectable</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/awt/ItemSelectable.html#getSelectedObjects()">getSelectedObjects</A></CODE></TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="isArmed()"><!-- --></A><H3>isArmed</H3><PRE>public boolean <B>isArmed</B>()</PRE><DL><DD>Indicates partial commitment towards pressing the button.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>true if the button is armed, and ready to be pressed<DT><B>See Also: </B><DD><A HREF="../../javax/swing/ButtonModel.html#setArmed(boolean)"><CODE>setArmed(boolean)</CODE></A></DL></DD></DL><HR><A NAME="isSelected()"><!-- --></A><H3>isSelected</H3><PRE>public boolean <B>isSelected</B>()</PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -