com.tensegrity.gui.swing.control
Class SwingMenu

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.AbstractButton
                  extended byjavax.swing.JMenuItem
                      extended byjavax.swing.JMenu
                          extended bycom.tensegrity.gui.swing.control.SwingMenu
All Implemented Interfaces:
javax.accessibility.Accessible, BasicComponent, Evaluable, java.awt.image.ImageObserver, java.awt.ItemSelectable, Menu, java.awt.MenuContainer, javax.swing.MenuElement, java.io.Serializable, javax.swing.SwingConstants

public class SwingMenu
extends javax.swing.JMenu
implements Menu

The custom Menu class which is capable of changing the icons of the MenuItems according to the current LookAndFeel.

Version:
$Id: SwingMenu.java,v 1.22 2006/02/03 11:00:27 BurkhardWick Exp $
Author:
GillesIachelini
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JMenu
javax.swing.JMenu.AccessibleJMenu, javax.swing.JMenu.WinListener
 
Nested classes inherited from class javax.swing.JMenuItem
javax.swing.JMenuItem.AccessibleJMenuItem
 
Nested classes inherited from class javax.swing.AbstractButton
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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
 
Field Summary
 
Fields inherited from class javax.swing.JMenu
popupListener
 
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
SwingMenu()
          Creates a new Menu.
SwingMenu(javax.swing.Action a)
          Creates a new Menu from the given Action.
SwingMenu(java.lang.String s)
          Creates a new Menu with the given String as title.
 
Method Summary
 java.awt.Component add(java.awt.Component c)
           
 java.awt.Component add(java.awt.Component c, int index)
           
 void add(java.awt.Component comp, java.lang.Object constraints)
           
 void add(java.awt.Component comp, java.lang.Object constraints, int index)
           
 javax.swing.JMenuItem add(javax.swing.JMenuItem menuItem)
           
 void add(java.awt.PopupMenu popup)
           
 java.awt.Component add(java.lang.String name, java.awt.Component comp)
           
 javax.swing.JMenuItem addEx(javax.swing.JMenuItem menuItem)
          This method delegates the add call directly to the super class without further checking.
 void addSeparator()
          Appends a separator of default size to the end of the tool bar.
 void applyEvList()
          Tells the component to apply its UIItemEvaluationList.
 void clearBogusSeparator()
          This method removes unwanted separators from the menu.
 java.lang.String getId()
          Returns the id of this menuitem.
 BasicComponent getParentComponent()
          Returns the parent Component of this instance.
protected  void init()
          The method init can be seen as drain for all sort of initialization.
 void installEvList()
          Tells the component to setup its internal state.
 SwingMenu removeMenu(java.lang.String id)
          Removes the SwingMenu with the parameter id from this menu and returns it.
 java.awt.Component removeMenuItem(java.lang.String id)
          Removes the SwingUtil.CommandMenuItem associated with the command with the parameter id.
 void setBackground(java.awt.Color bg)
          This method is overwritten to filter out unnecessary calls to setBackground.
 void setId(java.lang.String id)
          Sets the id of this menuitem.
 void setPopupMenuVisible(boolean b)
          This method was overwritten to add a state-updater to the contained menuitems.
 void updateUI()
          Invokes base class version of the updateUI command and checks whether the icons of the MenuItems have to be switched or not.
 
Methods inherited from class javax.swing.JMenu
add, add, addMenuListener, applyComponentOrientation, configurePropertiesFromAction, createActionChangeListener, createActionComponent, createWinListener, doClick, fireMenuCanceled, fireMenuDeselected, fireMenuSelected, getAccessibleContext, getComponent, getDelay, getItem, getItemCount, getMenuComponent, getMenuComponentCount, getMenuComponents, getMenuListeners, getPopupMenu, getPopupMenuOrigin, getSubElements, getUIClassID, insert, insert, insert, insertSeparator, isMenuComponent, isPopupMenuVisible, isSelected, isTearOff, isTopLevelMenu, menuSelectionChanged, paramString, processKeyEvent, remove, remove, remove, removeAll, removeMenuListener, setAccelerator, setComponentOrientation, setDelay, setMenuLocation, setModel, setSelected
 
Methods inherited from class javax.swing.JMenuItem
addMenuDragMouseListener, addMenuKeyListener, createActionPropertyChangeListener, fireMenuDragMouseDragged, fireMenuDragMouseEntered, fireMenuDragMouseExited, fireMenuDragMouseReleased, fireMenuKeyPressed, fireMenuKeyReleased, fireMenuKeyTyped, getAccelerator, getMenuDragMouseListeners, getMenuKeyListeners, init, isArmed, processKeyEvent, processMenuDragMouseEvent, processMenuKeyEvent, processMouseEvent, removeMenuDragMouseListener, removeMenuKeyListener, setArmed, setEnabled, setUI
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createChangeListener, createItemListener, 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, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setMargin, setMnemonic, setMnemonic, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, 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, getPropertyChangeListeners, getPropertyChangeListeners, 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, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, 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, 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, repaint, repaint, repaint, resize, resize, setBounds, setBounds, 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
 
Methods inherited from interface com.tensegrity.gui.component.BasicComponent
getHeight, getWidth, repaint
 
Methods inherited from interface javax.swing.MenuElement
processKeyEvent, processMouseEvent
 

Constructor Detail

SwingMenu

public SwingMenu()
Creates a new Menu.


SwingMenu

public SwingMenu(java.lang.String s)
Creates a new Menu with the given String as title.

Parameters:
s - the title of the new menu.

SwingMenu

public SwingMenu(javax.swing.Action a)
Creates a new Menu from the given Action.

Parameters:
a - the action to be associated with this command.
Method Detail

add

public java.awt.Component add(java.awt.Component c)

add

public java.awt.Component add(java.awt.Component c,
                              int index)

add

public javax.swing.JMenuItem add(javax.swing.JMenuItem menuItem)

addEx

public javax.swing.JMenuItem addEx(javax.swing.JMenuItem menuItem)
This method delegates the add call directly to the super class without further checking. This allows users of this class to be still able to add empty menu's.

Parameters:
menuItem - The menu item to add.
Returns:
the added menu item.
See Also:
JMenu.add(javax.swing.JMenuItem)

addSeparator

public void addSeparator()
Appends a separator of default size to the end of the tool bar. The default size is determined by the current look and feel. This method ignores the call, if there is already a separator at the end of the component list.

See Also:
JMenu.addSeparator()

add

public void add(java.awt.Component comp,
                java.lang.Object constraints)

add

public void add(java.awt.Component comp,
                java.lang.Object constraints,
                int index)

add

public void add(java.awt.PopupMenu popup)

add

public java.awt.Component add(java.lang.String name,
                              java.awt.Component comp)

init

protected void init()
The method init can be seen as drain for all sort of initialization. Place every init code into this method. It will be executed no matter what constructor was called.


clearBogusSeparator

public void clearBogusSeparator()
This method removes unwanted separators from the menu. These are separators which appear in the beginning of the menu or at the end. this method also invokes the #removeConsecutiveSeparator() to remove any consecutive separators.


updateUI

public void updateUI()
Invokes base class version of the updateUI command and checks whether the icons of the MenuItems have to be switched or not.

See Also:
#setIcon(String), JMenu.updateUI()

setBackground

public void setBackground(java.awt.Color bg)
This method is overwritten to filter out unnecessary calls to setBackground. The background of nicely working should change only in the rare case the user of the class triggers it through LnF changes. No other system is allowed to fiddle with our colors.

See Also:
JComponent.setBackground(java.awt.Color)

setPopupMenuVisible

public void setPopupMenuVisible(boolean b)
This method was overwritten to add a state-updater to the contained menuitems. Each time the menu has to made visible the isEnabled state of the contained items gets updated.

See Also:
JMenu.setPopupMenuVisible(boolean)

removeMenu

public SwingMenu removeMenu(java.lang.String id)
Removes the SwingMenu with the parameter id from this menu and returns it. This method returns null if no such SwingMenu was found.

Parameters:
id - the id of the menu to remove.
Returns:
the removed menu or null if no such menu was found.

removeMenuItem

public java.awt.Component removeMenuItem(java.lang.String id)
Removes the SwingUtil.CommandMenuItem associated with the command with the parameter id.

Parameters:
id - the id of the element to remove.
Returns:
the removed MenuItem or null, if no such element was found.

getId

public java.lang.String getId()
Returns the id of this menuitem. Optional.

Returns:
the associated ID.

setId

public void setId(java.lang.String id)
Sets the id of this menuitem.

Parameters:
id - the new id of this SwinMenu.

getParentComponent

public BasicComponent getParentComponent()
Description copied from interface: BasicComponent
Returns the parent Component of this instance.

Specified by:
getParentComponent in interface BasicComponent
Returns:
the parent component or null if no parent exists.

applyEvList

public void applyEvList()
Description copied from interface: Evaluable
Tells the component to apply its UIItemEvaluationList.

Specified by:
applyEvList in interface Evaluable

installEvList

public void installEvList()
Description copied from interface: Evaluable
Tells the component to setup its internal state.

Specified by:
installEvList in interface Evaluable


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.