javax.swing
Class JCheckBoxMenuItem

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JMenuItem
javax.swing.JCheckBoxMenuItem
- All Implemented Interfaces:
- javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, MenuElement, java.io.Serializable, SwingConstants
- public class JCheckBoxMenuItem
- extends JMenuItem
- implements SwingConstants, javax.accessibility.Accessible
A menu item that displays a checkbox. Its behaviour is very similar
to JCheckBox. Just like the JCheckBox, user can check
and uncheck this menu item by clicking on it. Also
AbstractButton.setSelected(boolean) 55 and setState(boolean) 55 can be use used
for the same purpose.
JCheckBoxMenuItem uses
ToggleButtonModel to keep track of its selection.
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Fields inherited from class javax.swing.JMenuItem |
|
| Fields inherited from class javax.swing.AbstractButton |
action, actionListener, actionPropertyChangeListener, BORDER_PAINTED_CHANGED_PROPERTY, borderPainted, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, contentAreaFilled, current_icon, default_icon, disabeldIcon, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, disabledSelectedIcon, FOCUS_PAINTED_CHANGED_PROPERTY, focusPainted, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, horizontalAlignment, horizontalTextPosition, ICON_CHANGED_PROPERTY, iconTextGap, itemListener, margin, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, mnemonicIndex, model, MODEL_CHANGED_PROPERTY, multiClickThreshhold, pressed_icon, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, rollOverEnabled, rolloverIcon, rolloverSelectedIcon, SELECTED_ICON_CHANGED_PROPERTY, selectedIcon, text, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY, verticalAlignment, verticalTextPosition |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, alignmentX, alignmentY, autoscrolls, border, debugGraphicsOptions, doubleBuffered, isCompletelyDirty, isPaintingDoubleBuffered, listenerList, maximumSize, minimumSize, opaque, preferredSize, requestFocusEnabled, TOOL_TIP_TEXT_KEY, toolTipText, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Methods inherited from class javax.swing.JMenuItem |
addMenuDragMouseListener, addMenuKeyListener, configurePropertiesFromAction, createActionPropertyChangeListener, fireMenuDragMouseDragged, fireMenuDragMouseEntered, fireMenuDragMouseExited, fireMenuDragMouseReleased, fireMenuKeyPressed, fireMenuKeyReleased, fireMenuKeyTyped, getAccelerator, getComponent, getMenuDragMouseListeners, getMenuKeyListeners, getSubElements, init, isArmed, menuSelectionChanged, processKeyEvent, processMenuDragMouseEvent, processMenuKeyEvent, processMouseEvent, removeMenuDragMouseListener, removeMenuKeyListener, setAccelerator, setArmed, setEnabled, setUI, updateUI |
| Methods inherited from class javax.swing.AbstractButton |
addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setUIProperty, setVerticalAlignment, setVerticalTextPosition |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, fireAncestorEvent, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, paintImmediately2, paintSimple, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateComponentInputMap |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
uiClassID
private static final java.lang.String uiClassID
- name for the UI delegate for this menuItem.
- See Also:
- Constant Field Values
state
private boolean state
- Indicates whether this menu item is checked.
selectedObjects
private java.lang.Object[] selectedObjects
- This array contains text of this menu item if this menu item is in
checked state and null it is not.
JCheckBoxMenuItem
public JCheckBoxMenuItem()
- Creates a new JCheckBoxMenuItem object.
JCheckBoxMenuItem
public JCheckBoxMenuItem(Icon icon)
- Creates a new JCheckBoxMenuItem with given icon
JCheckBoxMenuItem
public JCheckBoxMenuItem(java.lang.String text)
- Creates a new JCheckBoxMenuItem with given label
JCheckBoxMenuItem
public JCheckBoxMenuItem(Action action)
- Creates a new JCheckBoxMenuItem using given action
JCheckBoxMenuItem
public JCheckBoxMenuItem(java.lang.String text,
Icon icon)
- Creates a new JCheckBoxMenuItem object with given label and icon
JCheckBoxMenuItem
public JCheckBoxMenuItem(java.lang.String text,
boolean state)
- Creates a new JCheckBoxMenuItem object using specified label and
marked as checked if given 'state' is true.
JCheckBoxMenuItem
public JCheckBoxMenuItem(java.lang.String text,
Icon icon,
boolean state)
- Creates a new JCheckBoxMenuItem object with given label, icon,
and marked as checked if given 'state' is true.
getUIClassID
public java.lang.String getUIClassID()
- This method returns a name to identify which look and feel class will be
the UI delegate for the menuItem.
- Overrides:
getUIClassID in class JMenuItem
getState
public boolean getState()
- Returns checked state for this check box menu item.
setState
public void setState(boolean state)
- Sets state for this check box menu item. If
given 'state' is true, then mark menu item as checked,
and uncheck this menu item otherwise.
getSelectedObjects
public java.lang.Object[] getSelectedObjects()
- This method returns array containing label of this
menu item if it is selected and null otherwise.
- Specified by:
getSelectedObjects in interface java.awt.ItemSelectable- Overrides:
getSelectedObjects in class AbstractButton
requestFocus
public void requestFocus()
- This method overrides JComponent.requestFocus with an empty
implementation, since JCheckBoxMenuItems should not
receve focus in general.
- Overrides:
requestFocus in class JComponent
paramString
protected java.lang.String paramString()
- A string that describes this JCheckBoxMenuItem. Normally only used
for debugging.
- Overrides:
paramString in class JMenuItem
getAccessibleContext
public javax.accessibility.AccessibleContext getAccessibleContext()
- Description copied from interface:
javax.accessibility.Accessible
- If a component supports the Accessibility API then this method should
not return
null. Only classes which must extend an accessible
class, but must not itself be accessible, may return null.
- Specified by:
getAccessibleContext in interface javax.accessibility.Accessible- Overrides:
getAccessibleContext in class JMenuItem