javax.swing
public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants, Accessible
JCheckBox
, user can check
and uncheck this menu item by clicking on it. Also
AbstractButton and JCheckBoxMenuItem can be use used for
the same purpose. JCheckBoxMenuItem
uses
ToggleButtonModel
to keep track of its selection.
Nested Class Summary | |
---|---|
protected class | JCheckBoxMenuItem.AccessibleJCheckBoxMenuItem
Provides the accessibility features for the JCheckBoxMenuItem
component.
|
Constructor Summary | |
---|---|
JCheckBoxMenuItem()
Creates a new JCheckBoxMenuItem object. | |
JCheckBoxMenuItem(Icon icon)
Creates a new JCheckBoxMenuItem with given icon
| |
JCheckBoxMenuItem(String text)
Creates a new JCheckBoxMenuItem with given label
| |
JCheckBoxMenuItem(Action action)
Creates a new JCheckBoxMenuItem using given action
| |
JCheckBoxMenuItem(String text, Icon icon)
Creates a new JCheckBoxMenuItem object with given label and icon
| |
JCheckBoxMenuItem(String text, boolean state)
Creates a new JCheckBoxMenuItem object using specified label and marked as
checked if given 'state' is true.
| |
JCheckBoxMenuItem(String text, Icon icon, boolean state)
Creates a new JCheckBoxMenuItem object with given label, icon, and marked
as checked if given 'state' is true.
|
Method Summary | |
---|---|
AccessibleContext | getAccessibleContext()
Returns the object that provides accessibility features for this
JCheckBoxMenuItem component.
|
Object[] | getSelectedObjects()
This method returns array containing label of this menu item if it is
selected and null otherwise.
|
boolean | getState()
Returns checked state for this check box menu item.
|
String | getUIClassID()
This method returns a name to identify which look and feel class will be
the UI delegate for the menuItem.
|
protected String | paramString()
Returns a string describing the attributes for the
JCheckBoxMenuItem component, for use in debugging. |
void | requestFocus()
This method overrides JComponent.requestFocus with an empty implementation,
since JCheckBoxMenuItems should not receive focus in general. |
void | setState(boolean state)
Sets state for this check box menu item. |
Parameters: icon Icon for this menu item
Parameters: text Label for this menu item
Parameters: action Action for this menu item.
Parameters: text Label for this menu item icon Icon for this menu item
Parameters: text Label for this menu item state true
if this item should be in checked state
and false
otherwise
Parameters: text Label for this menu item icon icon for this menu item state true
if this item should be in checked state
and false otherwise
JCheckBoxMenuItem
component.
Returns: The accessible context (an instance of AccessibleJCheckBoxMenuItem).
Returns: Array containing label of this menu item if this menu item is selected or null otherwise.
Returns: Returns true if this menu item is in checked state and false otherwise.
Returns: The Look and Feel classID. "JCheckBoxMenuItemUI"
JCheckBoxMenuItem
component, for use in debugging. The
return value is guaranteed to be non-null
, but the format
of the string may vary between implementations.
Returns: A string describing the attributes of the
JCheckBoxMenuItem
.
Parameters: state new state for this menu item