dog.gui
Class DMenu

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--dog.gui.DContainer
                    |
                    +--dog.gui.DPopup
                          |
                          +--dog.gui.DMenu
All Implemented Interfaces:
java.awt.event.ComponentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, Referential, java.io.Serializable

public class DMenu
extends DPopup

A menu component to select an item.

This menu manages a list of items. It displays the items' icon (if any) and label, and generates action events.

To add a submenu to any menu item, add an item for which the reference is another menu. The handling of that menu will be performed automatically.

See Also:
Serialized Form

Inner Class Summary
 class DMenu.Separator
          A menu separator.
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected static java.awt.Dimension MINSMALLICONSIZE
          The minimum size that icons may be displayed at (16x16).
 
Fields inherited from class dog.gui.DPopup
ABOVE, BELOW, component, COMPONENT, componentWindow, fitMode, height, hideOnFocusLost, LEFT, MOVE, NONE, position, RESIZE, RIGHT, width
 
Fields inherited from class dog.gui.DContainer
cancelButton, CENTER, defaultButton, EAST, NORTH, NORTHEAST, NORTHWEST, reference, SOUTH, SOUTHEAST, SOUTHWEST, tooltip, WEST
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DMenu(DRootPane root)
          Constructs a menu.
 
Method Summary
 void add(DItem item)
          Adds an item to this menu.
 void add(DItem[] items)
          Add a number of items to this menu, in order.
 void addActionListener(java.awt.event.ActionListener listener)
          Adds the specified action listener to receive action events from this menu.
 void dispose()
          Clears this menu and its parents from the screen.
 int getItemCount()
          Returns the number of items in this menu.
 DItem[] getItems()
          Returns the items in this menu.
 DItem getParentItem()
          Returns the item that caused this submenu to be activated.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of this menu.
 DItem getSelected()
          Returns the selected item in this menu.
 boolean hasSubMenus()
          Indicates whether this menu contains submenus.
 boolean isFocusTraversable()
          This component is focus-traversable if it is not disabled.
 void paint(java.awt.Graphics g)
          Paints this menu.
protected  void processActionEvent(java.awt.event.ActionEvent event)
          Processes action events on this menu by dispatching them to any registered ActionListeners.
protected  void processEvent(java.awt.AWTEvent event)
          Processes events on this menu.
protected  void processKeyEvent(java.awt.event.KeyEvent event)
          Process key events.
protected  void processMouseEvent(java.awt.event.MouseEvent event)
          Process mouse events.
protected  void processMouseMotionEvent(java.awt.event.MouseEvent event)
          Process mouse motion events.
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes the specified action listener so it no longer receives action events from this menu.
 
Methods inherited from class dog.gui.DPopup
componentHidden, componentMoved, componentResized, componentShown, fit, getFont, getOffset, getOffset, paintBackground, processFocusEvent, setConstraints, setConstraints, setSize, setVisible
 
Methods inherited from class dog.gui.DContainer
addImpl, addPropertyChangeListener, alignParamString, drawActiveButtonBorder, drawActiveOptionBorder, drawArrow, drawBorder, drawButtonBorder, drawCheckbox, drawDarkBorder, drawDefaultButtonBorder, drawDisabledBorder, drawDisabledCheckbox, drawDisabledOption, drawExpander, drawFocusBorder, drawImage, drawLabel, drawOption, drawOptionBorder, drawPressedBorder, getCancelButton, getComponent, getDefaultButton, getDefaultToolkit, getImage, getImage, getImage, getReference, getRootPane, getTooltip, isPreloadImages, paramString, processCancelAction, processDefaultAction, removePropertyChangeListener, setCancelButton, setDefaultButton, setEnabled, setPreloadImages, setReference, setTooltip, toString
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setForeground, setLocale, setLocation, setLocation, setName, setSize, show, show, size, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MINSMALLICONSIZE

protected static final java.awt.Dimension MINSMALLICONSIZE
The minimum size that icons may be displayed at (16x16).
Constructor Detail

DMenu

public DMenu(DRootPane root)
Constructs a menu.
Method Detail

add

public void add(DItem item)
Adds an item to this menu.

add

public void add(DItem[] items)
Add a number of items to this menu, in order.

getItemCount

public int getItemCount()
Returns the number of items in this menu.

getItems

public DItem[] getItems()
Returns the items in this menu.

getSelected

public DItem getSelected()
Returns the selected item in this menu.

hasSubMenus

public boolean hasSubMenus()
Indicates whether this menu contains submenus.

getParentItem

public DItem getParentItem()
Returns the item that caused this submenu to be activated.

dispose

public void dispose()
Clears this menu and its parents from the screen.
Overrides:
dispose in class DPopup

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of this menu.
Overrides:
getPreferredSize in class java.awt.Container

paint

public void paint(java.awt.Graphics g)
Paints this menu.
Overrides:
paint in class DPopup

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds the specified action listener to receive action events from this menu.
Parameters:
listener - the action listener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes the specified action listener so it no longer receives action events from this menu.
Parameters:
listener - the action listener

processEvent

protected void processEvent(java.awt.AWTEvent event)
Processes events on this menu. If the event is an ActionEvent, it invokes the processActionEvent method. Otherwise it invokes the superclass processEvent.
Overrides:
processEvent in class DContainer
Parameters:
event - the event

processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent event)
Processes action events on this menu by dispatching them to any registered ActionListeners.
Parameters:
event - the action event

isFocusTraversable

public boolean isFocusTraversable()
This component is focus-traversable if it is not disabled.
Overrides:
isFocusTraversable in class java.awt.Component

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent event)
Process key events.
Overrides:
processKeyEvent in class DPopup

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent event)
Process mouse events.
Overrides:
processMouseEvent in class DContainer

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent event)
Process mouse motion events.
Overrides:
processMouseMotionEvent in class DContainer