📄 button.html
字号:
except that any specified icon is shown in addition to the normal check box icon. </td> </tr></table><p><table border=1><caption><a name="radiobuttonapi">Radio Button Constructors</a></caption><tr><th>Constructor</th><th>Purpose</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButton.html#JRadioButton(javax.swing.Action)">JRadioButton(Action)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButton.html#JRadioButton(java.lang.String)">JRadioButton(String)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButton.html#JRadioButton(java.lang.String, boolean)">JRadioButton(String, boolean)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButton.html#JRadioButton(javax.swing.Icon)">JRadioButton(Icon)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButton.html#JRadioButton(javax.swing.Icon, boolean)">JRadioButton(Icon, boolean)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButton.html#JRadioButton(java.lang.String, javax.swing.Icon)">JRadioButton(String, Icon)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButton.html#JRadioButton(java.lang.String, javax.swing.Icon, boolean)">JRadioButton(String, Icon, boolean)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButton.html#JRadioButton()">JRadioButton()</a> </td> <td>Create a <code>JRadioButton</code> instance. The string argument specifies the text, if any, that the radio button should display. Similarly, the <code>Icon</code> argument specifies the image that should be used instead of the look and feel's default radio button image. Specifying the boolean argument as <code>true</code> initializes the radio button to be selected, subject to the approval of the <code>ButtonGroup</code> object. If the boolean argument is absent or <code>false</code>, then the radio button is initially unselected. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButtonMenuItem.html#JRadioButtonMenuItem(javax.swing.Action)">JRadioButtonMenuItem(Action)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButtonMenuItem.html#JRadioButtonMenuItem(java.lang.String)">JRadioButtonMenuItem(String)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButtonMenuItem.html#JRadioButtonMenuItem(javax.swing.Icon)">JRadioButtonMenuItem(Icon)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButtonMenuItem.html#JRadioButtonMenuItem(java.lang.String, javax.swing.Icon)">JRadioButtonMenuItem(String, Icon)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JRadioButtonMenuItem.html#JRadioButtonMenuItem()">JRadioButtonMenuItem()</a> </td> <td>Create a <code>JRadioButtonMenuItem</code> instance. The arguments are interpreted in the same way as the arguments to the <code>JRadioButton</code> constructors, except that any specified icon is shown in addition to the normal radio button icon. </td> </tr></table><p><table border=1><caption><a name="togglebuttonapi">Toggle Button Constructors</a></caption><tr><th>Constructor</th><th>Purpose</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JToggleButton.html#JToggleButton(javax.swing.Action)">JToggleButton(Action)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JToggleButton.html#JToggleButton(java.lang.String)">JToggleButton(String)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JToggleButton.html#JToggleButton(java.lang.String, boolean)">JToggleButton(String, boolean)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JToggleButton.html#JToggleButton(javax.swing.Icon)">JToggleButton(Icon)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JToggleButton.html#JToggleButton(javax.swing.Icon, boolean)">JToggleButton(Icon, boolean)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JToggleButton.html#JToggleButton(java.lang.String, javax.swing.Icon)">JToggleButton(String, Icon)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JToggleButton.html#JToggleButton(java.lang.String, javax.swing.Icon, boolean)">JToggleButton(String, Icon, boolean)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/JToggleButton.html#JToggleButton()">JToggleButton()</a> </td> <td>Create a <code>JToggleButton</code> instance, which is similar to a <code>JButton</code>, but with two states. Normally, you use a <code>JRadioButton</code> or <code>JCheckBox</code> instead of directly instantiating <code>JToggleButton</code>, but <code>JToggleButton</code> can be useful when you don't want the typical radio button or check box appearance. The string argument specifies the text, if any, that the toggle button should display. Similarly, the <code>Icon</code> argument specifies the image that should be used. Specifying the boolean argument as <code>true</code> initializes the toggle button to be selected. If the boolean argument is absent or <code>false</code>, then the toggle button is initially unselected. </td> </tr></table><p><table border=1><caption><a name="buttongroup">Commonly Used Button Group Constructors/Methods</a></caption><tr><th>Constructor or Method</th><th>Purpose</th></tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/ButtonGroup.html#ButtonGroup()">ButtonGroup()</a> </td> <td>Create a <code>ButtonGroup</code> instance. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/ButtonGroup.html#add(javax.swing.AbstractButton)">void add(AbstractButton)</a> <br><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/ButtonGroup.html#remove(javax.swing.AbstractButton)">void remove(AbstractButton)</a> </td> <td>Add a button to the group, or remove a button from the group. </td> </tr> <tr> <td><a class="APILink" target="_blank" href="http://java.sun.com/javase/6/docs/api/javax/swing/DefaultButtonModel.html#getGroup()">public ButtonGroup getGroup()</a> <br> <em>(in <code>DefaultButtonModel</code>)</em> </td> <td>Get the <code>ButtonGroup</code>, if any, that controls a button. For example: <br> <code>ButtonGroup group = ((DefaultButtonModel)button.getModel()).getGroup();</code> </td> </tr></table></blockquote><h3><a name="eg">Examples that Use Various Kinds of Buttons</a></h3><blockquote>The following examples use buttons.Also see <a href="toolbar.html#eg">Examples that Use Tool Bars</a>,which lists programs that add <code>JButton</code> objectsto <code>JToolBar</code>s.<p><table><tr><th align=left> Example</th><th align=left> Where Described</th><th align=left> Notes</th></tr><tr><td> <a href="examples/index.html#ButtonDemo"><code>ButtonDemo</code></a></td><td> <a href="#abstractbutton">How to Use the Common Button API</a></td><td> Uses mnemonics and icons. Specifies the button text position, relative to the button icon. Uses action commands.</td></tr><tr><td> <a href="examples/index.html#ButtonHtmlDemo"><code>ButtonHtmlDemo</code></a></td><td> <a href="html.html">Using HTML in Swing Components</a></td><td> A version of ButtonDemo that uses HTML formatting in its buttons.</td></tr><tr><td> <a href="examples/index.html#ListDialog"><code>ListDialog</code></a></td><td> <a href="#jbutton">How to Use JButton Features</a></td><td> Implements a dialog with two buttons, one of which is the default button.</td></tr><tr><td> <a href="examples/index.html#DialogDemo"><code>DialogDemo</code></a></td><td> <a href="dialog.html">How to Make Dialogs</a></td><td> Has "Show it" buttons whose behavior is tied to the state of radio buttons. Uses sizable, though anonymous, inner classes to implement the action listeners. </td></tr><tr><td> <a href="examples/index.html#ProgressBarDemo"><code>ProgressBarDemo</code></a></td><td> <a href="progress.html">How to Monitor Progress</a></td><td> Implements a button's action listener with a named inner class.</td></tr><tr><td> <a href="examples/index.html#CheckBoxDemo"><code>CheckBoxDemo</code></a></td><td> <a href="#checkbox">How to Use Check Boxes</a></td><td> Uses check box buttons to determine which of 16 images it should display.</td></tr><tr><td> <a href="../misc/examples/index.html#ActionDemo"><code>ActionDemo</code></a></td><td> <a class="TutorialLink" target="_top" href="../misc/action.html">How to Use Actions</a></td><td> Uses check box menu items to set the state of the program.</td></tr><tr><td> <a href="examples/index.html#RadioButtonDemo"><code>RadioButtonDemo</code></a></td><td> <a href="#radiobutton">How to Use Radio Buttons</a></td><td> Uses radio buttons to determine which of five images it should display.</td></tr><tr><td> <a href="examples/index.html#DialogDemo"><code>DialogDemo</code></a></td><td> <a href="dialog.html">How to Make Dialogs</a></td><td> Contains several sets of radio buttons, which it uses to determine which dialog to bring up.</td></tr><tr><td> <a href="examples/index.html#MenuDemo"><code>MenuDemo</code></a></td><td> <a href="menu.html">How to Use Menus</a></td><td> Contains radio button menu items and check box menu items.</td></tr><tr><td> <a name="tbeg"> <ahref="examples/index.html#ColorChooserDemo2"><code>ColorChooserDemo2</code></a></a></td><td> <a href="colorchooser.html">How to Use Color Choosers</a><td> The crayons in <code>CrayonPanel</code> are implemented as toggle buttons.</tr><tr><td> <ahref="examples/index.html#ScrollDemo"><code>ScrollDemo</code></a></td><td> <a href="scrollpane.html">How to Use Scroll Panes</a><td> The <strong>cm</strong> button is a toggle button.</tr> </table> </blockquote> <div class=NavBit> <a target=_top href=applet.html>« Previous</a> • <a target=_top href=../TOC.html>Trail</a> • <a target=_top href=colorchooser.html>Next »</a> </div> </div> <div id=Footer><div id=TagNotes> Problems with the examples? Try <a target="_blank" href=../../information/run-examples.html>Compiling and Running the Examples: FAQs</a>. <br> Complaints? Compliments? Suggestions? <a target="_blank" href="http://developer.sun.com/contact/tutorial_feedback.jsp">Give us your feedback</a>.<br><br> <a target="_blank" href="../../information/copyright.html">Copyright</a> 1995-2006 Sun Microsystems, Inc. All rights reserved. <span id=Download></span></div> </div> <div class=PrintHeaders> <b>Previous page:</b> How to Make Applets <br><b>Next page:</b> How to Use Color Choosers </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -