Package uk.ac.starlink.topcat
Class ColumnComboBoxModel
- All Implemented Interfaces:
Serializable
,EventListener
,ComboBoxModel<TableColumn>
,TableColumnModelListener
,ListModel<TableColumn>
- Direct Known Subclasses:
RestrictedColumnComboBoxModel
public class ColumnComboBoxModel
extends AbstractListModel<TableColumn>
implements TableColumnModelListener, ComboBoxModel<TableColumn>
Adaptor class which turns a
TableColumnModel
into a ComboBoxModel
. This model is designed
to reflect the contents of a column model rather than the other
way around, so in general you wouldn't want to add a ListDataListener
to this model, you'd add it to the underlying column model.
Selections in the column model are not reflected by selections in this model, but columns added/moved/removed are.
- Author:
- Mark Taylor (Starlink)
- See Also:
-
Field Summary
FieldsFields inherited from class javax.swing.AbstractListModel
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionColumnComboBoxModel
(TableColumnModel colModel, boolean hasNone) Constructs a new ComboBoxModel based on a given column model, optionally with a null entry at the head of the list. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
void
void
getElementAt
(int index) int
getSize()
Returns a new JComboBox based on this model.void
setHasNone
(boolean hasNone) Sets whether there should be a null entry at the head of the list.void
setSelectedItem
(Object item) The selecteditem
must be aTableColumn
object.Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
-
Field Details
-
NO_COLUMN
public static final uk.ac.starlink.table.gui.StarTableColumn NO_COLUMN
-
-
Constructor Details
-
ColumnComboBoxModel
Constructs a new ComboBoxModel based on a given column model, optionally with a null entry at the head of the list.- Parameters:
colModel
- the column modelhasNone
- true iff an additional null entry at the head of the list is required
-
-
Method Details
-
setHasNone
public void setHasNone(boolean hasNone) Sets whether there should be a null entry at the head of the list.- Parameters:
hasNone
- true iff an additional null entry at the head of the list is required
-
getColumnModel
-
getElementAt
- Specified by:
getElementAt
in interfaceListModel<TableColumn>
-
getSize
public int getSize()- Specified by:
getSize
in interfaceListModel<TableColumn>
-
getSelectedItem
- Specified by:
getSelectedItem
in interfaceComboBoxModel<TableColumn>
-
setSelectedItem
The selecteditem
must be aTableColumn
object.- Specified by:
setSelectedItem
in interfaceComboBoxModel<TableColumn>
- Parameters:
item
- a table column to select
-
makeComboBox
Returns a new JComboBox based on this model. This convenience method, as well as installing this model into a new JComboBox instance, also installs a suitable renderer for displaying the elements.- Returns:
- new combo box displaying this model
- See Also:
-
columnAdded
- Specified by:
columnAdded
in interfaceTableColumnModelListener
-
columnRemoved
- Specified by:
columnRemoved
in interfaceTableColumnModelListener
-
columnMoved
- Specified by:
columnMoved
in interfaceTableColumnModelListener
-
columnMarginChanged
- Specified by:
columnMarginChanged
in interfaceTableColumnModelListener
-
columnSelectionChanged
- Specified by:
columnSelectionChanged
in interfaceTableColumnModelListener
-