|
Holger's Java API |
|||||||||
| 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
com.antelmann.util.gui.JMultipleSelectionComboBox
public class JMultipleSelectionComboBox
a specialized JComboBox allowing to deal with multiple selection.
This special JComboBox - upon double-mouse-click - provides a multiple-select search list
that is reflected in the JComboBox's method JComboBox.getSelectedObjects()
and displays a special multiple-select object when a multiple selection is present.
It uses a DefaultComboBoxModel, which may at times contain a special 'multipleSelect'-Object.
Note that getSelectedItem() may return an irritating value (a 'multiple-select' object),
which indicates that there is a multiple selection present; thus it is recommended to always call
getSelectedObjects() to obtain the correct selection.
This class does not implement EditableComponent as the semantics are different than
the implementation of the method names in a JComboBox; instead, setEditable(boolean) is
disabled for this implementation.
Note: be careful not to use renderer that cannot deal with the multiple selection!
FormattedCellRenderer.wrapForFormatException(java.text.Format),
Serialized Form| 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 |
|---|
| 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 com.antelmann.util.Enabled |
|---|
FILTER |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
JMultipleSelectionComboBox(Collection<?> items,
Object... initialSelection)
|
|
JMultipleSelectionComboBox(Object[] items,
Object... initialSelection)
|
|
JMultipleSelectionComboBox(String dialogTitle,
Object[] items,
Object... initialSelection)
|
|
| Method Summary | |
|---|---|
boolean |
containsAllSelect()
|
boolean |
containsNoSelect()
|
boolean |
containsSpecialSelectionOption(String title)
|
protected JPopupMenu |
createPopupMenu()
|
Object[] |
getContainedElements(Object... objects)
returns those objects from the given array that are also elements of this model |
ListCellRenderer |
getDialogRenderer()
|
String |
getDialogTitle()
|
Object[] |
getItems()
|
DefaultComboBoxModel |
getModel()
|
Object |
getSelectedItem()
Deprecated. use getSelectedObjects() instead |
Object[] |
getSelectedObjects()
|
JMultipleSelectionComboBox |
insertAllSelectOption()
puts a special item at the top of the list model that allows to select all entries (if it didn't already exist) |
JMultipleSelectionComboBox |
insertNoSelectOption()
puts a special item at the top of the list model that allows to select no entries (if it didn't already exist) |
JMultipleSelectionComboBox |
insertSpecialSelectionOption(String title,
Object... selection)
puts a special item at the top of the list model that allows to select a given predefined selection by a name |
boolean |
isAllowNoSelection()
if false, the dialog prevents returning with no selected elements |
boolean |
removeAllSelectOption()
removes the 'select all' option if it existed |
boolean |
removeNoSelectOption()
removes the 'no selection' option if it existed |
boolean |
removeSpecialSelectionOption(String title)
|
void |
setAllowNoSelection(boolean allowNoSelection)
allows to specify whether the dialog prevents returning with no selected elements (default is true). |
void |
setDialogRenderer(ListCellRenderer dialogRenderer)
|
void |
setDialogTitle(String dialogTitle)
|
void |
setEditable(boolean flag)
|
void |
setModel(ComboBoxModel aModel)
|
void |
setModelData(Object... listData)
delegates to the model and adjusts the current selection accordingly |
void |
setSelectedObjects(Object... selection)
|
protected void |
showDialog()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.antelmann.util.Enabled |
|---|
isEnabled, setEnabled |
| Constructor Detail |
|---|
public JMultipleSelectionComboBox(Collection<?> items,
Object... initialSelection)
public JMultipleSelectionComboBox(Object[] items,
Object... initialSelection)
public JMultipleSelectionComboBox(String dialogTitle,
Object[] items,
Object... initialSelection)
| Method Detail |
|---|
protected JPopupMenu createPopupMenu()
public Object[] getItems()
public ListCellRenderer getDialogRenderer()
public void setDialogRenderer(ListCellRenderer dialogRenderer)
public boolean isAllowNoSelection()
setAllowNoSelection(boolean)public void setAllowNoSelection(boolean allowNoSelection)
isAllowNoSelection(),
insertNoSelectOption()protected void showDialog()
public JMultipleSelectionComboBox insertNoSelectOption()
public JMultipleSelectionComboBox insertAllSelectOption()
public Object[] getContainedElements(Object... objects)
public JMultipleSelectionComboBox insertSpecialSelectionOption(String title,
Object... selection)
throws IllegalArgumentException
IllegalArgumentExceptionpublic boolean containsSpecialSelectionOption(String title)
public boolean removeSpecialSelectionOption(String title)
public boolean removeNoSelectOption()
public boolean removeAllSelectOption()
public boolean containsNoSelect()
public boolean containsAllSelect()
public String getDialogTitle()
public void setDialogTitle(String dialogTitle)
public void setSelectedObjects(Object... selection)
public Object[] getSelectedObjects()
getSelectedObjects in interface ItemSelectablegetSelectedObjects in class JComboBox@Deprecated public Object getSelectedItem()
getSelectedObjects() instead
getSelectedItem in class JComboBoxpublic void setModel(ComboBoxModel aModel)
setModel in class JComboBoxpublic void setEditable(boolean flag)
setEditable in class JComboBoxpublic DefaultComboBoxModel getModel()
getModel in class JComboBoxpublic void setModelData(Object... listData)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||