edu.neu.ccs.gui
Class Dropdown

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
All Implemented Interfaces:
Accessible, ActionListener, Displayable, EventListener, ImageObserver, ItemSelectable, JPTConstants, ListDataListener, MenuContainer, Serializable, SwingConstants
Direct Known Subclasses:
DropdownView, StringObjectDropdown

public class Dropdown
extends JComboBox
implements Displayable, JPTConstants

Class Dropdown provides the base functionality for dropdown lists.

The class extends the functionality of JComboBox.

In turn, this class is the base class for DropdownView and for StringObjectDropdown.

Since:
2.3.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 static String DEFAULT_SELECTION
          Default initially selected label for a dropdown view.
static int DEFAULT_WIDTH
          The default preferred width used in constructors if there is no other data with which to set the width.
protected  String defaultViewState
          The default view state.
protected  Vector itemList
          The list of current items.
protected  int minimumWidth
          The current minimum width for automatic width computations.
static String PREFERRED_WIDTH
          Bound property name for the set preferred width property.
protected  int preferredWidth
          The current preferred width if one is enabled or -1 if preferred width is disabled.
 
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.Displayable
DEFAULT_VIEW_STATE, 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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Dropdown()
          Constructs a view with no initial items.
Dropdown(Font font)
          Constructs a view with no initial items and the given font.
Dropdown(Font font, int minWidth)
          Constructs a view with no initial items, the given font, and the given minimum width.
Dropdown(int minWidth)
          Constructs a view with no initial items and the given minimum width.
Dropdown(String[] items)
          Constructs a view with the given array of items, for which the first item is selected by default.
Dropdown(String[] items, Font font)
          Constructs a view with the given array of items, for which the first item is selected by default and with the given font.
Dropdown(String[] items, Font font, int minWidth)
          Constructs a view with the given array of items, for which the first item is selected by default and with the given font and minimum width.
Dropdown(String[] items, int minWidth)
          Constructs a view with the given array of items, for which the first item is selected by default and with the given minimum width.
Dropdown(String[] items, String selection)
          Constructs a view with the given array of items, for which the given selection is selected by default.
Dropdown(String[] items, String selection, boolean editable)
          Constructs a view with the given array of items, for which the given selection is selected by default, and with the given editable state.
Dropdown(String[] items, String selection, Font font)
          Constructs a view with the given array of items, for which the given selection is selected by default and with the given font.
Dropdown(String[] items, String selection, Font font, boolean editable)
          Constructs a view with the given array of items, for which the given selection is selected by default, and with the given font and editable state.
Dropdown(String[] items, String selection, Font font, int minWidth)
          Constructs a view with the given array of items, for which the given selection is selected by default, and with the given font and minimum width.
Dropdown(String[] items, String selection, Font font, int minWidth, boolean editable)
          Constructs a view with the given array of items, for which the given selection is selected by default, and with the given font, width, and editable state.
Dropdown(String[] items, String selection, int minWidth)
          Constructs a view with the given array of items, for which the given selection is selected by default, and with the given minimum width.
Dropdown(String[] items, String selection, int minWidth, boolean editable)
          Constructs a view with the given array of items, for which the given selection is selected by default, and with the given width and editable state.
 
Method Summary
 void addItem(Object item)
          Adds the item to the view by calling the method in the parent and also maintains a record that this item was added.
 void addItems(String[] items)
          Adds the given String array of items to the view.
 void autoSetPreferredWidth()
          Automatically sets the preferred width based on the current setting of the minimum width, the current items in the dropdown list, and the current font.
static Font getDefaultFont()
          Returns the default font for a JComboBox.
 String getDefaultViewState()
          Returns a String representation of the default view state for this object.
 String[] getItems()
          Returns an array of all items currently installed in the view.
 int getMinimumWidth()
          Returns the current minimum width setting.
 Dimension getPreferredSize()
          Returns the preferred size of this view.
 int getPreferredWidth()
          Returns the preferred width setting of this view.
 String getViewState()
          Returns the current contents of the view display.
protected  void initializeDropdown(String[] items, String selection, Font font, int minWidth, boolean editable)
          The initializer.
 void insertItemAt(Object item, int index)
          Inserts an item into the item list at a given index by calling the method in the parent and also maintains a record that this item was added at that position.
 void refresh()
          Refreshes the component in its parent window by calling autoSetPreferredWidth() and then repacking the parent window.
 void refreshComponent()
          Refreshes the component by repacking the parent window.
 void removeAllItems()
          Removes all items from the view by calling the method in the parent and also maintains a record that all items were removed.
 void removeItem(Object item)
          Removes the item from the view by calling the method in the parent and also maintains a record that this item was removed.
 void removeItemAt(int index)
          Removes an item from the item list at a given index by calling the method in the parent and also maintains a record that this item was removed from that position.
 void removeItems(String[] items)
          Removes the given array of items from the view.
 void reset()
          Resets the view state of this object to the default view state for this object.
 void setDefaultViewState(String data)
          Sets the default view state for this object to the data state represented by the given String data.
 void setFont(Font font)
          Sets the font for this component.
 void setItems(String[] items)
          Removes all items in the view and then adds the given String array of items to the view.
 void setMinimumWidth(int minWidth)
          Sets the minimum width for use in the method autoSetPreferredWidth.
 void setPreferredWidth(int width)
          Sets the preferred width of text portion of the view to the given width if the given width is positive.
 void setPreferredWidth(int minWidth, int samWidth)
          Sets the preferred width of the text portion of the view to be at least the given minimum width and sufficiently wide to include strings whose width is no greater than the given sample width.
 void setPreferredWidth(int minWidth, String sample)
          Sets the preferred width of the text portion of the view using the given minimum width and sample string.
 void setViewState(String data)
          Attempts to set the display area of this view to the given String data.
 
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.Displayable
setEnabled
 

Field Detail

PREFERRED_WIDTH

public static final String PREFERRED_WIDTH
Bound property name for the set preferred width property.

See Also:
Constant Field Values

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
The default preferred width used in constructors if there is no other data with which to set the width.

See Also:
Constant Field Values

DEFAULT_SELECTION

protected static final String DEFAULT_SELECTION
Default initially selected label for a dropdown view.

See Also:
Constant Field Values

preferredWidth

protected int preferredWidth
The current preferred width if one is enabled or -1 if preferred width is disabled.


minimumWidth

protected int minimumWidth
The current minimum width for automatic width computations.


itemList

protected Vector itemList
The list of current items.


defaultViewState

protected String defaultViewState
The default view state.

Constructor Detail

Dropdown

public Dropdown()
Constructs a view with no initial items.

Other constructors:


Dropdown

public Dropdown(int minWidth)
Constructs a view with no initial items and the given minimum width.

Parameters:
minWidth - the preferred minimum width
See Also:
Dropdown()

Dropdown

public Dropdown(Font font)
Constructs a view with no initial items and the given font.

Parameters:
font - the font for the view
See Also:
Dropdown()

Dropdown

public Dropdown(Font font,
                int minWidth)
Constructs a view with no initial items, the given font, and the given minimum width.

Parameters:
font - the font for the view
minWidth - the preferred minimum width
See Also:
Dropdown()

Dropdown

public Dropdown(String[] items)

Constructs a view with the given array of items, for which the first item is selected by default.

If the given array of items is null, no items are initially added to the view.

Parameters:
items - the array of dropdown items
See Also:
Dropdown()

Dropdown

public Dropdown(String[] items,
                int minWidth)

Constructs a view with the given array of items, for which the first item is selected by default and with the given minimum width.

If the given array of items is null, no items are initially added to the view.

Parameters:
items - the array of dropdown items
minWidth - the preferred minimum width
See Also:
Dropdown()

Dropdown

public Dropdown(String[] items,
                Font font)

Constructs a view with the given array of items, for which the first item is selected by default and with the given font.

If the given array of items is null, no items are initially added to the view.

Parameters:
items - the array of dropdown items
font - the font for the view
See Also:
Dropdown()

Dropdown

public Dropdown(String[] items,
                Font font,
                int minWidth)

Constructs a view with the given array of items, for which the first item is selected by default and with the given font and minimum width.

If the given array of items is null, no items are initially added to the view.

Parameters:
items - the array of dropdown items
font - the font for the view
minWidth - the preferred minimum width
See Also:
Dropdown()

Dropdown

public Dropdown(String[] items,
                String selection)

Constructs a view with the given array of items, for which the given selection is selected by default.

If the given array of items is null, no items are initially added to the view.

If the view is not editable and the selection is not in the array of items then the selection will set the default state but will not be displayed.

Parameters:
items - the array of dropdown items
selection - the default initial choice
See Also:
Dropdown()

Dropdown

public Dropdown(String[] items,
                String selecti