org.wings
Class SMenu

java.lang.Object
  extended by org.wings.SComponent
      extended by org.wings.SAbstractIconTextCompound
          extended by org.wings.SAbstractButton
              extended by org.wings.SButton
                  extended by org.wings.SMenuItem
                      extended by org.wings.SMenu
All Implemented Interfaces:
ItemSelectable, Serializable, Cloneable, LowLevelEventListener, Renderable

public class SMenu
extends SMenuItem

Aggregates various SMenuItems under a main header entry.

Author:
Andre Lison, Armin Haaf
See Also:
Serialized Form

Field Summary
protected  List menuItems
           
 
Fields inherited from class org.wings.SMenuItem
menuParent
 
Fields inherited from class org.wings.SAbstractButton
actionCommand, CHECKBOX, IMAGE_BUTTON, RADIOBUTTON, RESET_BUTTON, SUBMIT_BUTTON
 
Fields inherited from class org.wings.SAbstractIconTextCompound
changeEvent, changeListener, DISABLED_ICON, DISABLED_SELECTED_ICON, ENABLED_ICON, ICON_COUNT, PRESSED_ICON, ROLLOVER_ICON, ROLLOVER_SELECTED_ICON, SELECTED_ICON, SELECTOR_SELECTED
 
Fields inherited from class org.wings.SComponent
DONE_RENDERING, dynamicStyles, enabled, propertyChangeSupport, SELECTOR_ALL, START_RENDERING, visible, WHEN_FOCUSED_OR_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_FRAME
 
Constructor Summary
SMenu()
           
SMenu(SIcon i)
           
SMenu(String text)
           
SMenu(String text, SIcon icon)
           
 
Method Summary
 void add(SComponent menuItem)
          Add a menu item to this menu.
 void add(SMenuItem menuItem)
          Add a menu item to this menu.
 void add(String menuitem)
          Add a menu item to this menu.
 void addSeparator()
          Add a separator to this menu.
 SComponent getChild(int index)
          gets the n'th child of the menu.
 int getChildrenCount()
           
 SComponent getMenuComponent(int pos)
           
 int getMenuComponentCount()
          Return the number of items on the menu, including separators.
 double getWidthScaleFactor()
          Returns the scale factor for the width of the Menu components.
 boolean isPopupMenuVisible()
          Returns true if the menu's popup window is visible.
 void remove(int pos)
          Removes the menu item at specified index from the menu.
 void remove(SComponent comp)
          removes a specific menu item component.
 void removeAll()
          Remove all SMenuItem from this menu.
 void setAccelerator(KeyStroke keyStroke)
           
 void setCG(MenuBarCG cg)
           
 void setEnabled(boolean enabled)
          Set wether this component should be enabled.
 void setParentFrame(SFrame f)
          Sets the parent frame.
 void setPopupMenuVisible(boolean b)
          Sets the visibility of the menu's popup.
 void setWidthScaleFactor(double widthScaleFactor)
          Sets the scale factor for the width of the Menu components.
 void writePopup(Device device)
           
 
Methods inherited from class org.wings.SMenuItem
getAccelerator, getParentMenu, getResidesInForm, isRecursivelyVisible
 
Methods inherited from class org.wings.SButton
fireFinalEvents, getSelectionParameter, isSelected, processLowLevelEvent, setGroup
 
Methods inherited from class org.wings.SAbstractButton
addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, doClick, fireActionPerformed, fireIntermediateEvents, getAction, getActionCommand, getActionListeners, getDeselectionParameter, getEventTarget, getGroup, getMnemonic, getToggleSelectionParameter, getType, isEpochCheckEnabled, isWordWrap, parseSelectionToggle, removeActionListener, setAction, setActionCommand, setCG, setEpochCheckEnabled, setEventTarget, setMnemonic, setSelected, setType, setWordWrap
 
Methods inherited from class org.wings.SAbstractIconTextCompound
addChangeListener, addItemListener, delayEvents, fireItemStateChanged, fireStateChanged, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getModel, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getSelectionBackground, getSelectionFont, getSelectionForeground, getText, getVerticalTextPosition, removeChangeListener, removeItemListener, setDisabledIcon, setDisabledSelectedIcon, setHorizontalTextPosition, setIcon, setIcons, setIconTextGap, setModel, setPressedIcon, setRolloverIcon, setRolloverSelectedIcon, setSelectedIcon, setSelectionBackground, setSelectionFont, setSelectionForeground, setText, setVerticalTextPosition, shouldDelayEvents
 
Methods inherited from class org.wings.SComponent
addComponentListener, addDynamicStyle, addEventListener, addNotify, addParentFrameListener, addPropertyChangeListener, addPropertyChangeListener, addRenderListener, addScriptListener, addStyle, clone, fireComponentChangeEvent, fireKeyEvents, fireRenderEvent, getActionMap, getBackground, getBorder, getCG, getClientProperty, getComponentPopupMenu, getDynamicStyle, getDynamicStyles, getFocusTraversalIndex, getFont, getForeground, getHorizontalAlignment, getInputMap, getInputMap, getListenerCount, getListenerList, getListeners, getLowLevelEventId, getName, getParent, getParentFrame, getPreferredSize, getRequestURL, getScriptListenerList, getScriptListeners, getSession, getShowAsFormComponent, getStyle, getToolTipText, getVerticalAlignment, invite, isDifferent, isEnabled, isFocusOwner, isReloadForced, isUpdatePossible, isVisible, paramString, processComponentEvent, processKeyEvents, putClientProperty, reload, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, removeComponentListener, removeDynamicStyle, removeEventListener, removeNotify, removeParentFrameListener, removePropertyChangeListener, removePropertyChangeListener, removeRenderListener, removeScriptListener, removeStyle, requestFocus, scrollRectToVisible, setActionMap, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setBackground, setBorder, setCG, setComponentPopupMenu, setDynamicStyles, setFocusTraversalIndex, setFont, setForeground, setHorizontalAlignment, setInputMap, setInputMap, setName, setNameRaw, setParent, setPreferredSize, setReloadForced, setShowAsFormComponent, setStyle, setToolTipText, setVerticalAlignment, setVisible, toString, update, updateCG, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.wings.LowLevelEventListener
getLowLevelEventId, getName, isEnabled
 

Field Detail

menuItems

protected final List menuItems
Constructor Detail

SMenu

public SMenu(String text)

SMenu

public SMenu()

SMenu

public SMenu(SIcon i)

SMenu

public SMenu(String text,
             SIcon icon)
Method Detail

add

public void add(SMenuItem menuItem)
Add a menu item to this menu.


add

public void add(SComponent menuItem)
Add a menu item to this menu.


addSeparator

public void addSeparator()
Add a separator to this menu.


setParentFrame

public void setParentFrame(SFrame f)
Description copied from class: SComponent
Sets the parent frame.

Overrides:
setParentFrame in class SAbstractButton
Parameters:
f - the frame

add

public void add(String menuitem)
Add a menu item to this menu.


getMenuComponent

public SComponent getMenuComponent(int pos)

getMenuComponentCount

public int getMenuComponentCount()
Return the number of items on the menu, including separators.


removeAll

public void removeAll()
Remove all SMenuItem from this menu.


remove

public void remove(int pos)
Removes the menu item at specified index from the menu.


remove

public void remove(SComponent comp)
removes a specific menu item component.


setCG

public void setCG(MenuBarCG cg)
Overrides:
setCG in class SMenuItem

setPopupMenuVisible

public void setPopupMenuVisible(boolean b)
Sets the visibility of the menu's popup. If the menu is not enabled, this method will have no effect.

Parameters:
b - a boolean value -- true to make the menu visible, false to hide it

isPopupMenuVisible

public boolean isPopupMenuVisible()
Returns true if the menu's popup window is visible.

Returns:
true if the menu is visible, else false.

getWidthScaleFactor

public double getWidthScaleFactor()
Returns the scale factor for the width of the Menu components. The length of the children texts is multiplied by this factor and set as width (in em) for the children.

Returns:
Returns the widthScaleFactor.

setWidthScaleFactor

public void setWidthScaleFactor(double widthScaleFactor)
Sets the scale factor for the width of the Menu components. The length of the children texts is multiplied by this factor and set as width (in em) for the children. Default value is 0.8.

Parameters:
widthScaleFactor - The widthScaleFactor to set.

getChildrenCount

public int getChildrenCount()
Returns:
Returns the amount of children elements.

getChild

public SComponent getChild(int index)
gets the n'th child of the menu. If the index is too high, returns null.

Parameters:
index - the index of the child to return
Returns:
the n'th child.

writePopup

public void writePopup(Device device)
                throws IOException
Throws:
IOException

setAccelerator

public void setAccelerator(KeyStroke keyStroke)
Overrides:
setAccelerator in class SMenuItem

setEnabled

public void setEnabled(boolean enabled)
Description copied from class: SComponent
Set wether this component should be enabled.

Overrides:
setEnabled in class SComponent
Parameters:
enabled - true if the component is enabled, false otherwise


wingS Swings ;-)