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 TypeClassDescription
protected classJCheckBoxMenuItem.AccessibleJCheckBoxMenuItemThis class implements accessibility support for the JcheckBoxMenuItem class.

Constructor

ConstructorDescription
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

ModifierMethodDescription
AccessibleContextgetAccessibleContext()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.
booleangetState()It returns the selected-state of the item.
StringgetUIClassID()It returns the name of the L&F class that renders this component.
protected StringparamString()It returns a string representation of this JCheckBoxMenuItem.
voidsetState(boolean b)It sets the selected-state of the item.

Java JCheckBoxMenuItem Example

Output:

Java JcheckBoxmenuitem
Next TopicJava JSeparator




Latest Courses