com.jgoodies.uif.component
Class UIFCheckBoxMenuItem

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.AbstractButton
                  extended by javax.swing.JMenuItem
                      extended by javax.swing.JCheckBoxMenuItem
                          extended by com.jgoodies.uif.component.UIFCheckBoxMenuItem
All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, MenuElement, SwingConstants

public final class UIFCheckBoxMenuItem
extends JCheckBoxMenuItem

A JCheckBoxMenuItem subclass that adds supports for temporarily invisible icons. Useful to hide icons on a specific platform or for a specific look&feel. For example the Mac Aqua style guide recommend to hide icons unless there's a special context such as a history menu.

The menu item's icon set can be made visible or invisible directly. But typically you should set the icon visible mode and use a Mode that describes when to

Version:
$Revision: 1.6 $
Author:
Karsten Lentzsch
See Also:
Mode, Modes, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JCheckBoxMenuItem
JCheckBoxMenuItem.AccessibleJCheckBoxMenuItem
 
Nested classes/interfaces inherited from class javax.swing.JMenuItem
JMenuItem.AccessibleJMenuItem
 
Nested classes/interfaces inherited from class javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
UIFCheckBoxMenuItem()
          Constructs a menu item with no set text or icon.
UIFCheckBoxMenuItem(Action action)
          Constructs a radio button menu item whose properties are taken from the specified Action.
UIFCheckBoxMenuItem(Icon icon)
          Constructs a menu item with the specified icon.
UIFCheckBoxMenuItem(Icon icon, boolean selected)
          Constructs a menu item with the specified icon.
UIFCheckBoxMenuItem(String text)
          Constructs a menu item with the specified text.
UIFCheckBoxMenuItem(String text, boolean selected)
          Constructs a radio button menu item with the specified text and selection state.
UIFCheckBoxMenuItem(String text, Icon icon)
          Constructs a menu item with the specified text and icon.
UIFCheckBoxMenuItem(String text, Icon icon, boolean selected)
          Constructs a radio button menu item that has the specified text, image, and selection state.
UIFCheckBoxMenuItem(String text, Icon icon, int mnemonic)
          Constructs a menu item with the specified text, icon and keyboard mnemonic.
UIFCheckBoxMenuItem(String text, Icon icon, int mnemonic, boolean selected)
          Constructs a menu item with the specified text, icon and keyboard mnemonic.
UIFCheckBoxMenuItem(String text, int mnemonic)
          Constructs a menu item with the specified text and keyboard mnemonic.
UIFCheckBoxMenuItem(String text, int mnemonic, boolean selected)
          Constructs a menu item with the specified text and keyboard mnemonic.
UIFCheckBoxMenuItem(ToggleAction toggleAction)
          Constructs a radio button menu item whose properties are taken from the specified ToggleAction.
 
Method Summary
protected  void configurePropertiesFromAction(Action a)
          In addition to the superclass behavior, this class sets the displayed mnemonic index if and only if the action provides one under key "mnemonicIndex".
 Mode getIconVisibleMode()
          Returns the current icon mode that determines whether this item shows or hides an icon - if any.
 boolean isIconVisible()
          Answers whether icons are currently visible or hidden.
 void setIconVisible(boolean newVisible)
          Shows or hides this item's icons.
 void setIconVisibleMode(Mode newMode)
          Sets a new icon visible mode that determines whether this item shows or hides an icon - if any.
 void updateUI()
          In addition to the superclass behavior that updates the UI this method adds or removes the item's icon according to the icon visible mode's current enabled value - if any.
 
Methods inherited from class javax.swing.JCheckBoxMenuItem
getAccessibleContext, getSelectedObjects, getState, getUIClassID, paramString, setState
 
Methods inherited from class javax.swing.JMenuItem
actionPropertyChanged, addMenuDragMouseListener, addMenuKeyListener, fireMenuDragMouseDragged, fireMenuDragMouseEntered, fireMenuDragMouseExited, fireMenuDragMouseReleased, fireMenuKeyPressed, fireMenuKeyReleased, fireMenuKeyTyped, getAccelerator, getComponent, getMenuDragMouseListeners, getMenuKeyListeners, getSubElements, init, isArmed, menuSelectionChanged, processKeyEvent, processMenuDragMouseEvent, processMenuKeyEvent, processMouseEvent, removeMenuDragMouseListener, removeMenuKeyListener, setAccelerator, setArmed, setEnabled, setModel, setUI
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, 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, removeNotify, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, 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, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem()
Constructs a menu item with no set text or icon.


UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(Icon icon)
Constructs a menu item with the specified icon.

Parameters:
icon - the icon of the menu item

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(String text)
Constructs a menu item with the specified text.

Parameters:
text - the text of the menu item

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(String text,
                           boolean selected)
Constructs a radio button menu item with the specified text and selection state.

Parameters:
text - the text of the menu item
selected - the selected state of the menu item

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(Icon icon,
                           boolean selected)
Constructs a menu item with the specified icon.

Parameters:
icon - the icon of the menu item
selected - the selected state of the menu item

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(Action action)
Constructs a radio button menu item whose properties are taken from the specified Action.

Parameters:
action - the action that provides the properties

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(ToggleAction toggleAction)
Constructs a radio button menu item whose properties are taken from the specified ToggleAction. Also sets the menu item's model to the model provided by the toggle action.

Parameters:
toggleAction - the action that provides the properties

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(String text,
                           Icon icon)
Constructs a menu item with the specified text and icon.

Parameters:
text - the text of the menu item
icon - the icon of the menu item

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(String text,
                           Icon icon,
                           boolean selected)
Constructs a radio button menu item that has the specified text, image, and selection state. All other constructors defer to this one.

Parameters:
text - the string displayed on the radio button
icon - the image that the button should display
selected - if true, the button is initially selected; otherwise, the button is initially unselected

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(String text,
                           int mnemonic)
Constructs a menu item with the specified text and keyboard mnemonic.

Parameters:
text - the text of the menu item
mnemonic - the keyboard mnemonic for the menu item

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(String text,
                           int mnemonic,
                           boolean selected)
Constructs a menu item with the specified text and keyboard mnemonic.

Parameters:
text - the text of the menu item
mnemonic - the keyboard mnemonic for the menu item
selected - if true, the button is initially selected; otherwise, the button is initially unselected

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(String text,
                           Icon icon,
                           int mnemonic)
Constructs a menu item with the specified text, icon and keyboard mnemonic.

Parameters:
text - the text of the menu item
icon - the icon of the menu item
mnemonic - the keyboard mnemonic for the menu item

UIFCheckBoxMenuItem

public UIFCheckBoxMenuItem(String text,
                           Icon icon,
                           int mnemonic,
                           boolean selected)
Constructs a menu item with the specified text, icon and keyboard mnemonic.

Parameters:
text - the text of the menu item
icon - the icon of the menu item
mnemonic - the keyboard mnemonic for the menu item
selected - if true, the button is initially selected; otherwise, the button is initially unselected
Method Detail

isIconVisible

public boolean isIconVisible()
Answers whether icons are currently visible or hidden.

Returns:
true if icons are visible, false if invisible

setIconVisible

public void setIconVisible(boolean newVisible)
Shows or hides this item's icons. In case the icons are hidden they are stored in private fields so they can be restored later.

The current implementations override icons during the restoring proces that have been set between the hide and show actions.

Parameters:
newVisible - true for visible, false for invisible

getIconVisibleMode

public Mode getIconVisibleMode()
Returns the current icon mode that determines whether this item shows or hides an icon - if any.

Returns:
the current icon mode

setIconVisibleMode

public void setIconVisibleMode(Mode newMode)
Sets a new icon visible mode that determines whether this item shows or hides an icon - if any.

Parameters:
newMode - the icon visible mode to be set

configurePropertiesFromAction

protected void configurePropertiesFromAction(Action a)
In addition to the superclass behavior, this class sets the displayed mnemonic index if and only if the action provides one under key "mnemonicIndex".

Overrides:
configurePropertiesFromAction in class JMenuItem
Parameters:
a - the Action from which to get the properties, or null
See Also:
Action

updateUI

public void updateUI()
In addition to the superclass behavior that updates the UI this method adds or removes the item's icon according to the icon visible mode's current enabled value - if any.

Overrides:
updateUI in class JMenuItem


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.