Package uk.ac.starlink.topcat
Class ColumnComboBoxModel
- java.lang.Object
-
- javax.swing.AbstractListModel<javax.swing.table.TableColumn>
-
- uk.ac.starlink.topcat.ColumnComboBoxModel
-
- All Implemented Interfaces:
java.io.Serializable,java.util.EventListener,javax.swing.ComboBoxModel<javax.swing.table.TableColumn>,javax.swing.event.TableColumnModelListener,javax.swing.ListModel<javax.swing.table.TableColumn>
- Direct Known Subclasses:
RestrictedColumnComboBoxModel
public class ColumnComboBoxModel extends javax.swing.AbstractListModel<javax.swing.table.TableColumn> implements javax.swing.event.TableColumnModelListener, javax.swing.ComboBoxModel<javax.swing.table.TableColumn>Adaptor class which turns aTableColumnModelinto aComboBoxModel. 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static uk.ac.starlink.table.gui.StarTableColumnNO_COLUMN
-
Constructor Summary
Constructors Constructor Description ColumnComboBoxModel(javax.swing.table.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcolumnAdded(javax.swing.event.TableColumnModelEvent evt)voidcolumnMarginChanged(javax.swing.event.ChangeEvent evt)voidcolumnMoved(javax.swing.event.TableColumnModelEvent evt)voidcolumnRemoved(javax.swing.event.TableColumnModelEvent evt)voidcolumnSelectionChanged(javax.swing.event.ListSelectionEvent evt)javax.swing.table.TableColumnModelgetColumnModel()javax.swing.table.TableColumngetElementAt(int index)java.lang.ObjectgetSelectedItem()intgetSize()javax.swing.JComboBox<javax.swing.table.TableColumn>makeComboBox()Returns a new JComboBox based on this model.voidsetHasNone(boolean hasNone)Sets whether there should be a null entry at the head of the list.voidsetSelectedItem(java.lang.Object item)The selected item must be aTableColumnobject.-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
-
-
-
Constructor Detail
-
ColumnComboBoxModel
public ColumnComboBoxModel(javax.swing.table.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.- Parameters:
colModel- the column modelhasNone- true iff an additional null entry at the head of the list is required
-
-
Method Detail
-
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
public javax.swing.table.TableColumnModel getColumnModel()
-
getElementAt
public javax.swing.table.TableColumn getElementAt(int index)
- Specified by:
getElementAtin interfacejavax.swing.ListModel<javax.swing.table.TableColumn>
-
getSize
public int getSize()
- Specified by:
getSizein interfacejavax.swing.ListModel<javax.swing.table.TableColumn>
-
getSelectedItem
public java.lang.Object getSelectedItem()
- Specified by:
getSelectedItemin interfacejavax.swing.ComboBoxModel<javax.swing.table.TableColumn>
-
setSelectedItem
public void setSelectedItem(java.lang.Object item)
The selected item must be aTableColumnobject.- Specified by:
setSelectedItemin interfacejavax.swing.ComboBoxModel<javax.swing.table.TableColumn>- Parameters:
item- a table column to select
-
makeComboBox
public javax.swing.JComboBox<javax.swing.table.TableColumn> 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:
ColumnCellRenderer
-
columnAdded
public void columnAdded(javax.swing.event.TableColumnModelEvent evt)
- Specified by:
columnAddedin interfacejavax.swing.event.TableColumnModelListener
-
columnRemoved
public void columnRemoved(javax.swing.event.TableColumnModelEvent evt)
- Specified by:
columnRemovedin interfacejavax.swing.event.TableColumnModelListener
-
columnMoved
public void columnMoved(javax.swing.event.TableColumnModelEvent evt)
- Specified by:
columnMovedin interfacejavax.swing.event.TableColumnModelListener
-
columnMarginChanged
public void columnMarginChanged(javax.swing.event.ChangeEvent evt)
- Specified by:
columnMarginChangedin interfacejavax.swing.event.TableColumnModelListener
-
columnSelectionChanged
public void columnSelectionChanged(javax.swing.event.ListSelectionEvent evt)
- Specified by:
columnSelectionChangedin interfacejavax.swing.event.TableColumnModelListener
-
-