Java JCheckBoxMenuItem
JCheckBoxMenuItem class represents checkbox which can be included on a menu . A CheckBoxMenuItem can have text or a graphic icon or both, associated with it. MenuItem can be selected or deselected. MenuItems can be configured and controlled by actions.
Nested class
Modifier and Type |
Class |
Description |
protected class |
JCheckBoxMenuItem.AccessibleJCheckBoxMenuItem |
This class implements accessibility support for the JcheckBoxMenuItem class. |
Constructor
Constructor |
Description |
JCheckBoxMenuItem() |
It creates an initially unselected check box menu item with no set text or icon. |
JCheckBoxMenuItem(Action a) |
It creates a menu item whose properties are taken from the Action supplied. |
JCheckBoxMenuItem(Icon icon) |
It creates an initially unselected check box menu item with an icon. |
JCheckBoxMenuItem(String text) |
It creates an initially unselected check box menu item with text. |
JCheckBoxMenuItem(String text, boolean b) |
It creates a check box menu item with the specified text and selection state. |
JCheckBoxMenuItem(String text, Icon icon) |
It creates an initially unselected check box menu item with the specified text and icon. |
JCheckBoxMenuItem(String text, Icon icon, boolean b) |
It creates a check box menu item with the specified text, icon, and selection state. |
Methods
Modifier |
Method |
Description |
AccessibleContext |
getAccessibleContext() |
It gets the AccessibleContext associated with this JCheckBoxMenuItem. |
Object[] |
getSelectedObjects() |
It returns an array (length 1) containing the check box menu item label or null if the check box is not selected. |
boolean |
getState() |
It returns the selected-state of the item. |
String |
getUIClassID() |
It returns the name of the L&F class that renders this component. |
protected String |
paramString() |
It returns a string representation of this JCheckBoxMenuItem. |
void |
setState(boolean b) |
It sets the selected-state of the item. |
Java JCheckBoxMenuItem Example
Output:
|