|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JComboBox
edu.neu.ccs.gui.Dropdown
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.
| 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 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 |
public static final String PREFERRED_WIDTH
public static final int DEFAULT_WIDTH
protected static final String DEFAULT_SELECTION
protected int preferredWidth
protected int minimumWidth
protected Vector itemList
protected String defaultViewState
| Constructor Detail |
public Dropdown()
Other constructors:
- Dropdown(int)
- Dropdown(Font)
- Dropdown(Font, int)
- Dropdown(String[])
- Dropdown(String[], int)
- Dropdown(String[], Font)
- Dropdown(String[], Font, int)
- Dropdown(String[], String)
- Dropdown(String[], String, int)
- Dropdown(String[], String, Font)
- Dropdown(String[], String, Font, int)
- Dropdown(String[], String, boolean)
- Dropdown(String[], String, int, boolean)
- Dropdown(String[], String, Font, boolean)
- Dropdown(String[], String, Font, int, boolean)
public Dropdown(int minWidth)
minWidth - the preferred minimum widthDropdown()public Dropdown(Font font)
font - the font for the viewDropdown()
public Dropdown(Font font,
int minWidth)
font - the font for the viewminWidth - the preferred minimum widthDropdown()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.
items - the array of dropdown itemsDropdown()
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.
items - the array of dropdown itemsminWidth - the preferred minimum widthDropdown()
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.
items - the array of dropdown itemsfont - the font for the viewDropdown()
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.
items - the array of dropdown itemsfont - the font for the viewminWidth - the preferred minimum widthDropdown()
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.
items - the array of dropdown itemsselection - the default initial choiceDropdown()
public Dropdown(String[] items,
String selecti