|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JComboBox com.cleancode.swing.JComboBoxMgr
public class JComboBoxMgr
Manages a JComboBox
using a most-recently-used model.
That is, the most-recently-used item percolates to the top of the list.
So typed-in items go on the top and items selected by the mouse move to the top.
Methods used to perform common operations are shown in the table.
action | methods |
---|---|
add | addItem (or by typing text into the JComboBox) |
retrieve | getItemAt, getSelectedItem |
remove | removeItem, removeItemAt, removeSelectedItem, removeAllItems |
change selection | advance |
addItem
method always adds the item to the top of the
list and makes it the selected item.
No duplicates are permitted. If a new entry is entered which already
exists, that entry is simply advanced to the top of the list.
The advance
method, then, is the only way to have the selected item be
other than the top item.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComboBox |
---|
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String |
VERSION
Current version of this class. |
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.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JComboBoxMgr()
Creates a new JComboBoxMgr ,
a wrapper for an editable JComboBox . |
Method Summary | |
---|---|
void |
addItem(Object anObject)
Inserts the specified item at the top of the JComboBox . |
void |
addTypedItem(Object anObject)
Called in response to user events on the JComboBox as
well as to changes instigated by other methods of this class. |
void |
advance(int increment)
Advances the selected item pointer by the specified increment . |
boolean |
isModified()
Indicates whether the underlying JComboBox has been updated since
program invocation. |
void |
removeAllItems()
Empties the JComboBox . |
void |
removeItem(Object item)
Removes the specified item from the JComboBox . |
void |
removeItemAt(int index)
Removes the specified item from the JComboBox . |
void |
removeSelectedItem()
Removes the selected item from the JComboBox . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String VERSION
Constructor Detail |
---|
public JComboBoxMgr()
JComboBoxMgr
,
a wrapper for an editable JComboBox
.
Method Detail |
---|
public void addItem(Object anObject)
JComboBox
.
This overrides the superclass method to insert the item at the top
without duplication.
addItem
in class JComboBox
anObject
- item to insertpublic void removeAllItems()
JComboBox
.
This overrides the superclass method to prevent the property change
from being propagated.
removeAllItems
in class JComboBox
public void removeItemAt(int index)
JComboBox
.
This overrides the superclass method to prevent the property change
from being propagated.
removeItemAt
in class JComboBox
index
- index of specified item to removepublic void removeItem(Object item)
JComboBox
.
This overrides the superclass method to prevent the property change
from being propagated.
removeItem
in class JComboBox
item
- specified item Object to removepublic void removeSelectedItem()
JComboBox
.
public void advance(int increment)
increment
.
The increment may be positive or negative. The list represented by the
JComboBox
is considered to be circular so it will wrap from
first-to-last or last-to-first as necessary.
Note that the newly selected item is not moved to the top when
selected in this fashion (typically via Next and Previous commands).
The increment is typically +1 or -1, but may be an arbitrary number. If
the increment causes a wrap in either direction, however, the component
is advanced just to the first item past the wrap.
increment
- positive or negative number of frames to advancepublic void addTypedItem(Object anObject)
JComboBox
as
well as to changes instigated by other methods of this class.
First fire the VetoableChange. If not rejected, add the item, then
fire the PropertyChange. (The item is not added in "navigation-mode"
which is typically "next" and "previous" movements.)
anObject
- Object to addpublic boolean isModified()
JComboBox
has been updated since
program invocation.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
CleanCode Java Libraries | Copyright © 2001-2012 Michael Sorens - Revised 2012.12.10 |