edu.neu.ccs.gui
Class StringObjectDropdown

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JComboBox
                  extended byedu.neu.ccs.gui.Dropdown
                      extended byedu.neu.ccs.gui.StringObjectDropdown
All Implemented Interfaces:
Accessible, ActionListener, Displayable, EventListener, ImageObserver, ItemSelectable, JPTConstants, ListDataListener, MenuContainer, Serializable, StringObjectView, SwingConstants

public class StringObjectDropdown
extends Dropdown
implements StringObjectView

A view based on JComboBox for the selection of an object using an associated string in a StringObjectMap.

It is invalid to modify the items in this view after construction by using methods of the base class. This view should not be made editable.

Since:
2.3
Version:
2.3.3
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComboBox
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  StringObjectMap pairmap
          The internal two way map.
protected  boolean sort
          Whether or not to sort.
 
Fields inherited from class edu.neu.ccs.gui.Dropdown
DEFAULT_SELECTION, DEFAULT_WIDTH, defaultViewState, itemList, minimumWidth, PREFERRED_WIDTH, preferredWidth
 
Fields inherited from class javax.swing.JComboBox
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder
 
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.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface edu.neu.ccs.gui.StringObjectView
VIEW_STATE
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
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 edu.neu.ccs.gui.Displayable
DEFAULT_VIEW_STATE, VIEW_STATE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
StringObjectDropdown()
          The default constructor.
StringObjectDropdown(Object[][] pairs)
          The constructor that uses a pairs array to construct the internal two way map.
StringObjectDropdown(Object[][] pairs, Action action)
          The constructor that uses a pairs array to construct the internal two way map; and provides the action to perform when an option is selected.
StringObjectDropdown(Object[][] pairs, Action action, boolean sort)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(Object[][] pairs, Action action, Font font)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and provides the font.
StringObjectDropdown(Object[][] pairs, Action action, Font font, boolean sort)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(Object[][] pairs, Action action, Font font, int minWidth)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; and provides the minimum width for the drop down list.
StringObjectDropdown(Object[][] pairs, Action action, Font font, int minWidth, boolean sort)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(Object[][] pairs, Action action, int minWidth)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and provides the minimum width for the drop down list.
StringObjectDropdown(Object[][] pairs, Action action, int minWidth, boolean sort)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(StringObjectMap map)
          The constructor that copies the given string-object map to construct the internal string-object map.
StringObjectDropdown(StringObjectMap map, Action action)
          The constructor that copies the given string-object map to construct the internal string-object map; and provides the action to perform when an option is selected.
StringObjectDropdown(StringObjectMap map, Action action, boolean sort)
          The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(StringObjectMap map, Action action, Font font)
          The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected and provides the font.
StringObjectDropdown(StringObjectMap map, Action action, Font font, boolean sort)
          The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; provides the font; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(StringObjectMap map, Action action, Font font, int minWidth)
          The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; provides the font; and provides the minimum width for the drop down list.
StringObjectDropdown(StringObjectMap map, Action action, Font font, int minWidth, boolean sort)
          The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; provides the font; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(StringObjectMap map, Action action, int minWidth)
          The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; and provides the minimum width for the drop down list.
StringObjectDropdown(StringObjectMap map, Action action, int minWidth, boolean sort)
          The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(StringObjectPair[] pairs)
          The constructor that uses a pairs array to construct the internal two way map.
StringObjectDropdown(StringObjectPair[] pairs, Action action)
          The constructor that uses a pairs array to construct the internal two way map; and provides the action to perform when an option is selected.
StringObjectDropdown(StringObjectPair[] pairs, Action action, boolean sort)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(StringObjectPair[] pairs, Action action, Font font)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and provides the font.
StringObjectDropdown(StringObjectPair[] pairs, Action action, Font font, boolean sort)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(StringObjectPair[] pairs, Action action, Font font, int minWidth)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; and provides the minimum width for the drop down list.
StringObjectDropdown(StringObjectPair[] pairs, Action action, Font font, int minWidth, boolean sort)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.
StringObjectDropdown(StringObjectPair[] pairs, Action action, int minWidth)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and provides the minimum width for the drop down list.
StringObjectDropdown(StringObjectPair[] pairs, Action action, int minWidth, boolean sort)
          The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.
 
Method Summary
 void addPair(String string, Object object)
          Adds the new pair with the given string and object.
 void addPair(StringObjectPair pair)
          Adds the new string-object pair.
 void addPairs(Object[][] pairs)
          Adds the new pairs.
 void addPairs(StringObjectMap map)
          Adds the new map.
 void addPairs(StringObjectPair[] pairs)
          Adds the new pairs.
 Object getObject(String string)
          Returns the Object associated with the given String in this view or null if no association is found.
 Object[] getObjects()
          Returns the objects associated with the strings in this view.
 Object getSelectedObject()
          Returns the object corresponding to the currently selected string in the view.
 String getSelectedString()
          Returns the currently selected string in the view.
 String getString(Object object)
          Returns the String associated with the given Object in this view or null if no association is found.
 StringObjectPair[] getStringObjectPairs()
          Returns the string object pairs in this view.
 String[] getStrings()
          Returns the strings in this view.
protected  void initializeSODropdown(StringObjectPair[] pairs, Action action, Font font, int minWidth, boolean sort)
          The initializer.
 void removeAllItems()
          Clears the data structure and view.
 void setFont(Font font)
          Sets the font for this component.
 void setPairs(Object[][] pairs)
          Clears the data structure and view and then adds the new pairs.
 void setPairs(StringObjectMap map)
          Clears the data structure and view and then adds the new map.
 void setPairs(StringObjectPair[] pairs)
          Clears the data structure and view and then adds the new pairs.
 void setSelectedObject(Object object)
          Sets the view to the string corresponding to the given object.
 void setSelectedString(String string)
          Sets the view to the string provided that the string is in the internal map.
 
Methods inherited from class edu.neu.ccs.gui.Dropdown
addItem, addItems, autoSetPreferredWidth, getDefaultFont, getDefaultViewState, getItems, getMinimumWidth, getPreferredSize, getPreferredWidth, getViewState, initializeDropdown, insertItemAt, refresh, refreshComponent, removeItem, removeItemAt, removeItems, reset, setDefaultViewState, setItems, setMinimumWidth, setPreferredWidth, setPreferredWidth, setPreferredWidth, setViewState
 
Methods inherited from class javax.swing.JComboBox
actionPerformed, addActionListener, addItemListener, addPopupMenuListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, createDefaultKeySelectionManager, fireActionEvent, fireItemStateChanged, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyEvent, removeActionListener, removeItemListener, removePopupMenuListener, selectedItemChanged, selectWithKeyChar, setAction, setActionCommand, setEditable, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, setSelectedItem, setUI, showPopup, updateUI
 
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, 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, paintBorder, 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, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setForeground, 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, addImpl, applyComponentOrientation, 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, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, 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, 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, imageUpdate, 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, 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
 
Methods inherited from interface edu.neu.ccs.gui.StringObjectView
addActionListener, removeActionListener
 
Methods inherited from interface edu.neu.ccs.gui.Displayable
setEnabled
 

Field Detail

pairmap

protected StringObjectMap pairmap
The internal two way map.


sort

protected boolean sort
Whether or not to sort.

Constructor Detail

StringObjectDropdown

public StringObjectDropdown()

The default constructor.

Other constructors:


StringObjectDropdown

public StringObjectDropdown(Object[][] pairs)

The constructor that uses a pairs array to construct the internal two way map.

Parameters:
pairs - the string-object pairs to add
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(Object[][] pairs,
                            Action action)

The constructor that uses a pairs array to construct the internal two way map; and provides the action to perform when an option is selected.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(Object[][] pairs,
                            Action action,
                            int minWidth)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and provides the minimum width for the drop down list.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
minWidth - the preferred minimum width
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(Object[][] pairs,
                            Action action,
                            Font font)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and provides the font.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
font - the font for the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(Object[][] pairs,
                            Action action,
                            Font font,
                            int minWidth)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; and provides the minimum width for the drop down list.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
font - the font for the view
minWidth - the preferred minimum width
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(Object[][] pairs,
                            Action action,
                            boolean sort)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and allows the choice of whether or not to sort the strings.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(Object[][] pairs,
                            Action action,
                            int minWidth,
                            boolean sort)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
minWidth - the preferred minimum width
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(Object[][] pairs,
                            Action action,
                            Font font,
                            boolean sort)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; and allows the choice of whether or not to sort the strings.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
font - the font for the view
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(Object[][] pairs,
                            Action action,
                            Font font,
                            int minWidth,
                            boolean sort)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
font - the font for the view
minWidth - the preferred minimum width
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectPair[] pairs)

The constructor that uses a pairs array to construct the internal two way map.

Parameters:
pairs - the string-object pairs to add
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectPair[] pairs,
                            Action action)

The constructor that uses a pairs array to construct the internal two way map; and provides the action to perform when an option is selected.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectPair[] pairs,
                            Action action,
                            int minWidth)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and provides the minimum width for the drop down list.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
minWidth - the preferred minimum width
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectPair[] pairs,
                            Action action,
                            Font font)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and provides the font.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
font - the font for the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectPair[] pairs,
                            Action action,
                            Font font,
                            int minWidth)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; and provides the minimum width for the drop down list.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
font - the font for the view
minWidth - the preferred minimum width
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectPair[] pairs,
                            Action action,
                            boolean sort)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; and allows the choice of whether or not to sort the strings.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectPair[] pairs,
                            Action action,
                            int minWidth,
                            boolean sort)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
minWidth - the preferred minimum width
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectPair[] pairs,
                            Action action,
                            Font font,
                            boolean sort)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; and allows the choice of whether or not to sort the strings.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
font - the font for the view
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectPair[] pairs,
                            Action action,
                            Font font,
                            int minWidth,
                            boolean sort)

The constructor that uses a pairs array to construct the internal two way map; provides the action to perform when an option is selected; provides the font; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
font - the font for the view
minWidth - the preferred minimum width
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectMap map)

The constructor that copies the given string-object map to construct the internal string-object map.

Parameters:
map - the string-object map to add
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectMap map,
                            Action action)

The constructor that copies the given string-object map to construct the internal string-object map; and provides the action to perform when an option is selected.

Parameters:
map - the string-object map to add
action - the action to perform when an option is selected
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectMap map,
                            Action action,
                            int minWidth)

The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; and provides the minimum width for the drop down list.

Parameters:
map - the string-object map to add
action - the action to perform when an option is selected
minWidth - the preferred minimum width
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectMap map,
                            Action action,
                            Font font)

The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected and provides the font.

Parameters:
map - the string-object map to add
action - the action to perform when an option is selected
font - the font for the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectMap map,
                            Action action,
                            Font font,
                            int minWidth)

The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; provides the font; and provides the minimum width for the drop down list.

Parameters:
map - the string-object map to add
action - the action to perform when an option is selected
font - the font for the view
minWidth - the preferred minimum width
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectMap map,
                            Action action,
                            boolean sort)

The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; and allows the choice of whether or not to sort the strings.

Parameters:
map - the string-object map to add
action - the action to perform when an option is selected
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectMap map,
                            Action action,
                            int minWidth,
                            boolean sort)

The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.

Parameters:
map - the string-object map to add
action - the action to perform when an option is selected
minWidth - the preferred minimum width
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectMap map,
                            Action action,
                            Font font,
                            boolean sort)

The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; provides the font; and allows the choice of whether or not to sort the strings.

Parameters:
map - the string-object map to add
action - the action to perform when an option is selected
font - the font for the view
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()

StringObjectDropdown

public StringObjectDropdown(StringObjectMap map,
                            Action action,
                            Font font,
                            int minWidth,
                            boolean sort)

The constructor that copies the given string-object map to construct the internal string-object map; provides the action to perform when an option is selected; provides the font; provides the minimum width for the drop down list; and allows the choice of whether or not to sort the strings.

Parameters:
map - the string-object map to add
action - the action to perform when an option is selected
font - the font for the view
minWidth - the preferred minimum width
sort - whether or not to sort the strings before insertion in the view
See Also:
StringObjectDropdown()
Method Detail

initializeSODropdown

protected final void initializeSODropdown(StringObjectPair[] pairs,
                                          Action action,
                                          Font font,
                                          int minWidth,
                                          boolean sort)
The initializer.

Parameters:
pairs - the string-object pairs to add
action - the action to perform when an option is selected
font - the font for the view
minWidth - the preferred minimum width
sort - whether or not to sort the strings before insertion in the view

getSelectedString

public final String getSelectedString()

Returns the currently selected string in the view.

Specified by:
getSelectedString in interface StringObjectView
Returns:
the selected string
See Also:
getSelectedObject()

getSelectedObject

public final Object getSelectedObject()

Returns the object corresponding to the currently selected string in the view.

Specified by:
getSelectedObject in interface StringObjectView
Returns:
the selected object
See Also:
getSelectedString()

setSelectedString

public final void setSelectedString(String string)

Sets the view to the string provided that the string is in the internal map.

Does nothing if the string is null or is not in the internal map.

Does nothing if the view state will be unchanged.

Fires property change Displayable.VIEW_STATE.

Specified by:
setSelectedString in interface StringObjectView
Parameters:
string - the string to use to set the view
See Also:
setSelectedObject(Object)

setSelectedObject

public final void setSelectedObject(Object object)

Sets the view to the string corresponding to the given object.

Does nothing if the object is null or is not in the internal map.

Fires property change Displayable.VIEW_STATE.

Specified by:
setSelectedObject in interface StringObjectView
Parameters:
object - the object to use to set the view
See Also:
setSelectedString(String)

getStringObjectPairs

public final StringObjectPair[] getStringObjectPairs()

Returns the string object pairs in this view. The string object pairs are sorted if string sorting was specified in a constructor.

Returns:
the string object pairs in this view
See Also:
getStrings(), getObjects()

getStrings

public final String[] getStrings()

Returns the strings in this view. The strings are sorted if string sorting was specified in a constructor.

Returns:
the strings in this view
See Also:
getStringObjectPairs(), getObjects()

getObjects

public final Object[] getObjects()

Returns the objects associated with the strings in this view. The objects are sorted according to the ordering of the strings if string sorting was specified in a constructor.

Returns:
the objects associated with the strings in this view
See Also:
getStringObjectPairs(), getStrings()

getString

public final String getString(Object object)

Returns the String associated with the given Object in this view or null if no association is found.

Parameters:
object - the object to associate with a string
Returns:
the associated string or null
See Also:
getObject(String)

getObject

public final Object getObject(String string)

Returns the Object associated with the given String in this view or null if no association is found.

Parameters:
string - the string to associate with an object
Returns:
the associated object or null
See Also:
getString(Object)

setPairs

public final void setPairs(Object[][] pairs)

Clears the data structure and view and then adds the new pairs.

Parameters:
pairs - the string-object pairs to set
See Also:
setPairs(StringObjectPair[]), setPairs(StringObjectMap)

setPairs

public final void setPairs(StringObjectPair[] pairs)

Clears the data structure and view and then adds the new pairs.

Parameters:
pairs - the string-object pairs to set
See Also:
setPairs(Object[][]), setPairs(StringObjectMap)

setPairs

public final void setPairs(StringObjectMap map)

Clears the data structure and view and then adds the new map.

Parameters:
map - the string-object map to set
See Also:
setPairs(Object[][]), setPairs(StringObjectPair[])

addPair

public final void addPair(String string,
                          Object object)

Adds the new pair with the given string and object.

Parameters:
string - the string
object - the object
See Also:
addPair(StringObjectPair)

addPair

public final void addPair(StringObjectPair pair)

Adds the new string-object pair.

Parameters:
pair - the string-object pair

addPairs

public final void addPairs(Object[][] pairs)

Adds the new pairs.

Parameters:
pairs - the string-object pairs to add
See Also:
addPairs(StringObjectPair[]), addPairs(StringObjectMap)

addPairs

public final void addPairs(StringObjectPair[] pairs)

Adds the new pairs.

Parameters:
pairs - the string-object pairs to add
See Also:
addPairs(Object[][]), addPairs(StringObjectMap)

addPairs

public final void addPairs(StringObjectMap map)

Adds the new map.

Parameters:
map - the string-object map to add
See Also:
addPairs(Object[][]), addPairs(StringObjectPair[])

removeAllItems

public final void removeAllItems()

Clears the data structure and view.

Overrides:
removeAllItems in class Dropdown

setFont

public void setFont(Font font)

Sets the font for this component.

If the given font is null then it is set to getDefaultFont().

Fires property change FONT.

Overrides:
setFont in class Dropdown
Parameters:
font - the font to set for this view