dog.gui
Class DChoice

java.lang.Object
  |
  +--java.awt.Component
        |
        +--dog.gui.DComponent
              |
              +--dog.gui.DChoice
All Implemented Interfaces:
java.util.EventListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.beans.PropertyChangeListener, Referential, java.io.Serializable

public class DChoice
extends DComponent
implements java.awt.ItemSelectable, java.beans.PropertyChangeListener

A choice component with an associated popup list to select the current item. The popup list can be hierarchical, but it cannot be expanded or collapsed.

See Also:
Serialized Form

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.DComponent
CENTER, CENTER_TILE, changes, EAST, INTEGER_TILE, MAXIMIZE, MAXIMIZE_ASPECT, MAXIMIZE_HORIZONTAL, MAXIMIZE_VERTICAL, NORTH, NORTHEAST, NORTHWEST, reference, SOUTH, SOUTHEAST, SOUTHWEST, TILE, 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
DChoice()
          Constructs an empty choice.
DChoice(DFrame frame)
          Constructs an empty choice.
 
Method Summary
 void add(DItem item)
          Adds an item to the choice.
 void add(DItem[] items)
          Adds items to the choice.
 void add(DItem parent, DItem child)
          Adds an item to the choice as a child of the specified parent item.
 void add(DItem parent, DItem[] children)
          Adds items to the choice as children of the specified parent item.
 void addItemListener(java.awt.event.ItemListener listener)
          Adds the specified item listener to receive item events from this choice.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds the specified property change listener to receive property change events from this component.
 void clear()
          Clears the list.
 boolean contains(DItem item)
          Indicates whether this choice contains the specified item.
 DItem[] getChildren(DItem parent)
          Returns the children of the specified parent item.
 int getDepth(DItem item)
          Returns the depth of the specified item in the hierarchical tree.
 int getIndent()
          Returns the indentation of the items when displayed in tree form.
 DItem getItem(java.lang.Object reference)
          Returns the item in this choice with the specified reference, or null if no such item exists.
 int getItemCount()
          Returns the number of items in the choice.
 DItem[] getItems()
          Returns all the items in the choice.
 java.awt.Dimension getMaximumSize()
          Returns the maximum size for this choice.
 java.awt.Dimension getMinimumSize()
          Returns the minimum size for this choice.
 DItem getParent(DItem child)
          Returns the parent of the specified child item, or null if the child has no parent in this choice.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size for this choice.
 int getRootCount()
          Returns the number of root items in this choice.
 DItem[] getRoots()
          Returns the root items in this choice.
 DItem getSelected()
          Returns the selected item in this list.
 java.lang.Object[] getSelectedObjects()
          Returns the selected items in this list.
 java.lang.Object getSelectedReference()
          Returns the selected item's reference, if any.
 boolean hasChildren()
          Determines if this choice contains items that are children of other items.
 boolean isFilled()
          Indicates whether this choice is filled.
 boolean isFocusTraversable()
          This component is focus-traversable if it is not disabled.
 boolean isSelected(DItem item)
          Indicates whether the specified item is selected in this list.
 void paint(java.awt.Graphics g)
          Paints this choice.
 java.lang.String paramString()
          Returns the parameter string for this choice.
protected  void processEvent(java.awt.AWTEvent event)
          Processes events on this choice.
protected  void processFocusEvent(java.awt.event.FocusEvent event)
          Process focus events.
protected  void processItemEvent(java.awt.event.ItemEvent event)
          Processes item events on this component by dispatching them to any registered ItemListeners.
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 propertyChange(java.beans.PropertyChangeEvent event)
          An item in this list changed state.
 void remove(DItem item)
          Removes an item from the choice.
 void remove(DItem[] items)
          Removes items from the choice.
 void removeChildren(DItem parent)
          Removes an item's children from the list.
 void removeItemListener(java.awt.event.ItemListener listener)
          Removes the specified item listener so that it no longer receives item events from this choice.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes the specified property change listener so it no longer receives property change events from this component.
 void setFilled(boolean filled)
          Sets whether to fill this choice with the fill colour.
 void setIndent(int indent)
          Sets the indentation of the items when displayed in tree form.
 DItem setSelected(DItem item)
          Sets the selected item.
 DItem setSelected(java.lang.Object reference)
          Sets the selected item to be the first item in the choice with the specified reference.
 
Methods inherited from class dog.gui.DComponent
alignParamString, drawActiveButtonBorder, drawActiveOptionBorder, drawArrow, drawBackgroundImage, drawBorder, drawButtonBorder, drawCheckbox, drawDarkBorder, drawDefaultButtonBorder, drawDisabledBorder, drawDisabledCheckbox, drawDisabledOption, drawExpander, drawFocusBorder, drawImage, drawLabel, drawOption, drawOptionBorder, drawPressedBorder, drawTick, getDefaultToolkit, getImage, getImage, getImage, getReference, getRootPane, getRows, getTooltip, isPreloadImages, parseColor, parseFont, processCancelAction, processDefaultAction, setEnabled, setPreloadImages, setReference, setTooltip, toString
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus, update, validate
 
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

DChoice

public DChoice()
Constructs an empty choice.

DChoice

public DChoice(DFrame frame)
Constructs an empty choice. This constructor allows you to set an alternative frame to attach the popup to. This is because if the default frame has modal dialogs displayed against it, the popup will be disabled.
Method Detail

getIndent

public int getIndent()
Returns the indentation of the items when displayed in tree form. A negative value indicates that the indentation is calculated automatically.
See Also:
setIndent(int)

setIndent

public void setIndent(int indent)
Sets the indentation of the items when displayed in tree form. A negative value indicates that the indentation is to be calculated automatically.
See Also:
getIndent()

isFilled

public boolean isFilled()
Indicates whether this choice is filled.

setFilled

public void setFilled(boolean filled)
Sets whether to fill this choice with the fill colour.

getItems

public DItem[] getItems()
Returns all the items in the choice.

getItemCount

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

getItem

public DItem getItem(java.lang.Object reference)
Returns the item in this choice with the specified reference, or null if no such item exists. This method will not return an item with a null reference.

hasChildren

public boolean hasChildren()
Determines if this choice contains items that are children of other items.

getChildren

public DItem[] getChildren(DItem parent)
Returns the children of the specified parent item.
Parameters:
parent - the parent item

getParent

public DItem getParent(DItem child)
Returns the parent of the specified child item, or null if the child has no parent in this choice.
Parameters:
child - the child item

getDepth

public int getDepth(DItem item)
Returns the depth of the specified item in the hierarchical tree. Top-level items have a depth of 1. If the item is not in this list, this method returns 0.

getRoots

public DItem[] getRoots()
Returns the root items in this choice. Root items are items that have no parents.
See Also:
getRootCount()

getRootCount

public int getRootCount()
Returns the number of root items in this choice. Root items are items that have no parents.
See Also:
getRoots()

contains

public boolean contains(DItem item)
Indicates whether this choice contains the specified item.

add

public void add(DItem item)
Adds an item to the choice.
Parameters:
item - the item to add
See Also:
remove(dog.gui.DItem)

add

public void add(DItem parent,
                DItem child)
Adds an item to the choice as a child of the specified parent item. The parent item must already exist in the choice.
See Also:
remove(dog.gui.DItem), getChildren(DItem), getParent(DItem), getRoots()

add

public void add(DItem[] items)
Adds items to the choice.
See Also:
remove(dog.gui.DItem)

add

public void add(DItem parent,
                DItem[] children)
Adds items to the choice as children of the specified parent item. The parent item must already exist in the choice.
See Also:
remove(dog.gui.DItem)

remove

public void remove(DItem item)
Removes an item from the choice. If it has any children, these are also removed from the choice.
See Also:
add(DItem), removeChildren(DItem)

remove

public void remove(DItem[] items)
Removes items from the choice. If they have any children, these are also removed from the choice.
See Also:
add(DItem), removeChildren(DItem)

removeChildren

public void removeChildren(DItem parent)
Removes an item's children from the list.
See Also:
remove(DItem)

isSelected

public boolean isSelected(DItem item)
Indicates whether the specified item is selected in this list.

setSelected

public DItem setSelected(DItem item)
Sets the selected item.
Parameters:
item - the item to be selected
Returns:
the item if it was selected, null otherwise

setSelected

public DItem setSelected(java.lang.Object reference)
Sets the selected item to be the first item in the choice with the specified reference. This will not select an item with a null reference.
Parameters:
reference - the reference of the item to be selected
Returns:
the selected item, or null if no item was selected

getSelected

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

getSelectedReference

public java.lang.Object getSelectedReference()
Returns the selected item's reference, if any.

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Returns the selected items in this list. This method is semantically equivalent to getSelected(), which may be more useful, and is included only to implement ItemSelectable.
Specified by:
getSelectedObjects in interface java.awt.ItemSelectable

clear

public void clear()
Clears the list.

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size for this choice.
Overrides:
getMinimumSize in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size for this choice.
Overrides:
getPreferredSize in class java.awt.Component

getMaximumSize

public java.awt.Dimension getMaximumSize()
Returns the maximum size for this choice.
Overrides:
getMaximumSize in class java.awt.Component

paint

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

isFocusTraversable

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

addItemListener

public void addItemListener(java.awt.event.ItemListener listener)
Adds the specified item listener to receive item events from this choice.
Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
listener - the item listener

removeItemListener

public void removeItemListener(java.awt.event.ItemListener listener)
Removes the specified item listener so that it no longer receives item events from this choice.
Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
listener - the item listener

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds the specified property change listener to receive property change events from this component.
Overrides:
addPropertyChangeListener in class DComponent
Parameters:
listener - the property change listener

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the specified property change listener so it no longer receives property change events from this component.
Overrides:
removePropertyChangeListener in class DComponent
Parameters:
listener - the property change listener

processEvent

protected void processEvent(java.awt.AWTEvent event)
Processes events on this choice. If the event is an ItemEvent, it invokes the processItemEvent method.
Overrides:
processEvent in class DComponent
Parameters:
event - the event

processItemEvent

protected void processItemEvent(java.awt.event.ItemEvent event)
Processes item events on this component by dispatching them to any registered ItemListeners.
Parameters:
event - the item event

processFocusEvent

protected void processFocusEvent(java.awt.event.FocusEvent event)
Process focus events.
Overrides:
processFocusEvent in class java.awt.Component

processKeyEvent

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

processMouseEvent

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

processMouseMotionEvent

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

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
An item in this list changed state.
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

paramString

public java.lang.String paramString()
Returns the parameter string for this choice.
Overrides:
paramString in class DComponent