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 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.

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
minWidth - the preferred minimum width
See Also:
Dropdown()

Dropdown

public 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.

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
font - the font for the view
See Also:
Dropdown()

Dropdown

public 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.

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
font - the font for the view
minWidth - the preferred minimum width
See Also:
Dropdown()

Dropdown

public 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.

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 label for the initial default choice
editable - whether or not the view is user editable
See Also:
Dropdown()

Dropdown

public 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.

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 label for the initial default choice
minWidth - the preferred minimum width
editable - whether or not the view is user editable
See Also:
Dropdown()

Dropdown

public 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.

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 label for the initial default choice
font - the font for the view
editable - whether or not the view is user editable
See Also:
Dropdown()

Dropdown

public 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.

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 label for the initial default choice
font - the font for the view
minWidth - the preferred minimum width
editable - whether or not the view is user editable
See Also:
Dropdown()
Method Detail

initializeDropdown

protected void initializeDropdown(String[] items,
                                  String selection,
                                  Font font,
                                  int minWidth,
                                  boolean editable)
The initializer.

Parameters:
items - the array of dropdown items
selection - the label for the initial default choice
font - the font for the view
minWidth - the preferred minimum width
editable - whether or not the view is user editable

addItem

public 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.

This override of an inherited method will only add the item if it is a non-null instance of String.

To avoid multiple refresh operations after each add operation, this method does not auto refresh.

Parameters:
item - the item to add

insertItemAt

public 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.

This override of an inherited method will only insert the item if it is a non-null instance of String.

To avoid multiple refresh operations after each insert operation, this method does not auto refresh.

Parameters:
item - the item to add
index - the position at which to add the item

removeItem

public 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.

This override of an inherited method will only remove the item if it is a non-null instance of String.

To avoid multiple refresh operations after each remove operation, this method does not auto refresh.

Parameters:
item - the item to remove

removeItemAt

public 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.

To avoid multiple refresh operations after each remove operation, this method does not auto refresh.

Parameters:
index - the position at which to remove the item

removeAllItems

public 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.


addItems

public void addItems(String[] items)

Adds the given String array of items to the view.

Calls refresh() if items are added.

If the items array is null, then does nothing.

Parameters:
items - the items to be added

setItems

public void setItems(String[] items)

Removes all items in the view and then adds the given String array of items to the view.

Calls refresh() if items are added.

If the items array is null, then simply removes all items in the view and leaves the view empty.

Parameters:
items - the items to be added after removing existing items

removeItems

public void removeItems(String[] items)

Removes the given array of items from the view.

If the items array is null, then does nothing.

Parameters:
items - the items to be removed

getItems

public String[] getItems()
Returns an array of all items currently installed in the view.

Returns:
an array of all items

getPreferredSize

public Dimension getPreferredSize()

Returns the preferred size of this view.

This method proceeds as follows.

The preferred size is calculated by the super class method. Then, if the preferred width set in this class is positive, the width field of the preferred size is replaced by the sum of the preferred width and the height field of the preferred size. The preferred size then is returned.

This calculation is done so that the preferred width controls the width of the text portion of the dropdown and the actual width includes room for the control.

Returns:
the value of the preferredSize property

getPreferredWidth

public int getPreferredWidth()

Returns the preferred width setting of this view.

The value returned is positive or -1.

If the value is -1 then it is not used to compute the preferred size.

Returns:
the current preferred width of this view

autoSetPreferredWidth

public 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.

It is recommended that this method be used to set the width of the dropdown rather than an explicit call to one of the methods setPreferredWidth. This method is called in the constructors and in the method refresh().


setMinimumWidth

public void setMinimumWidth(int minWidth)

Sets the minimum width for use in the method autoSetPreferredWidth.

This minimum width will be interpreted later`as follows.


getMinimumWidth

public int getMinimumWidth()
Returns the current minimum width setting.


setPreferredWidth

public void setPreferredWidth(int width)

Sets the preferred width of text portion of the view to the given width if the given width is positive.

If the given width is zero, sets the preferred width of the text portion of the view to DEFAULT_WIDTH.

If the given width is negative, sets the preferred width to -1 and the preferred size of the view will be computed entirely from the data of the super class.

Refreshes the component in its parent view.

It is recommended that the user call the method autoSetPreferredWidth rather than call this method directly. This method is public for backward compatibility and to permit the user to set an absolute preferred width if that behavior is really desired.

Fires property change PREFERRED_WIDTH.

Parameters:
width - the desired preferred width

setPreferredWidth

public 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.

This method proceeds as follows.

If the sample string is null or of length zero, then the preferred width is set via the call: setPreferredWidth(minWidth).

Otherwise, if minWidth is zero, it is set to DEFAULT_WIDTH. Then, the method getSampleWidth is called using the current font of the view and the sample string. The preferred width is then set to be the maximum of minWidth and the sample width.

Always calls setMinimumWidth(minWidth) to save the minimum width setting.

Refreshes the component in its parent view.

It is recommended that the user call the method autoSetPreferredWidth rather than call this method directly. This method is public for backward compatibility and to permit the user to set a width larger than the width of any string installed in the dropdown list.

Fires property change PREFERRED_WIDTH.

Parameters:
minWidth - the minimum width
sample - the sample string used to calculate the width

setPreferredWidth

public 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.

Always calls setMinimumWidth(minWidth) to save the minimum width setting.

Refreshes the component in its parent view.

It is recommended that the user call the method autoSetPreferredWidth rather than call this method directly. This method is public for backward compatibility and to permit the user to set a width larger than the width of any string installed in the dropdown list.

Fires property change PREFERRED_WIDTH.

Parameters:
minWidth - the minimum width
samWidth - the maximum width of one or more sample strings
See Also:
setPreferredWidth(int), setPreferredWidth(int, String)

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.

Parameters:
font - the font to set for this view

getDefaultFont

public static Font getDefaultFont()
Returns the default font for a JComboBox.


setViewState

public void setViewState(String data)

Attempts to set the display area of this view to the given String data.

If isEditable() returns true then sets the editable display area to the String data.

If isEditable() returns false then changes the display area to the String data only if data is in the dropdown list.

In either case, if data is in the dropdown list then will also set the selected index to the first occurence of data in the dropdown list.

If data is null, then does nothing.

If the current view state already equals data then also does nothing.

Fires property change VIEW_STATE.

Specified by:
setViewState in interface Displayable
Parameters:
data - the String to be selected
See Also:
getViewState()

getViewState

public String getViewState()
Returns the current contents of the view display.

Specified by:
getViewState in interface Displayable
Returns:
the view state as a String
See Also:
setViewState(String)

setDefaultViewState

public void setDefaultViewState(String data)
Sets the default view state for this object to the data state represented by the given String data.

Specified by:
setDefaultViewState in interface Displayable
Parameters:
data - the new default data state for this object
See Also:
getDefaultViewState(), reset()

getDefaultViewState

public String getDefaultViewState()
Returns a String representation of the default view state for this object.

Specified by:
getDefaultViewState in interface Displayable
Returns:
the default view state as a String
See Also:
setDefaultViewState(String), reset()

reset

public void reset()
Resets the view state of this object to the default view state for this object.

Specified by:
reset in interface Displayable
See Also:
Displayable.setViewState(String), Displayable.getDefaultViewState()

refresh

public void refresh()

Refreshes the component in its parent window by calling autoSetPreferredWidth() and then repacking the parent window.


refreshComponent

public void refreshComponent()
Refreshes the component by repacking the parent window.