Package ucar.ui.table
Class TableAligner
- java.lang.Object
-
- ucar.ui.table.TableAligner
-
- All Implemented Interfaces:
EventListener
,TableColumnModelListener
public class TableAligner extends Object implements TableColumnModelListener
A listener that sets the alignment of cells in aJTable
. Expected usage:JTable table = new JTable(...); TableAligner aligner = new TableAligner(table, SwingConstants.XXXX); table.getColumnModel().addColumnModelListener(aligner);
-
-
Constructor Summary
Constructors Constructor Description TableAligner(JTable table, int alignment)
Creates a listener that installs alignment decorators on new columns added totable
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
columnAdded(TableColumnModelEvent e)
void
columnMarginChanged(ChangeEvent e)
void
columnMoved(TableColumnModelEvent e)
void
columnRemoved(TableColumnModelEvent e)
void
columnSelectionChanged(ListSelectionEvent e)
static void
installInAllColumns(JTable table, int alignment)
Installs alignment decorators in all of the table's columns.static void
installInOneColumn(JTable table, int colViewIndex, int alignment)
Installs alignment decorators in the table column atcolViewIndex
.
-
-
-
Constructor Detail
-
TableAligner
public TableAligner(JTable table, int alignment)
Creates a listener that installs alignment decorators on new columns added totable
. Also performs the initial alignment oftable
.- Parameters:
table
- a table.alignment
- one of the following constants:SwingConstants.LEFT
SwingConstants.CENTER
(the default for image-only labels)SwingConstants.RIGHT
SwingConstants.LEADING
(the default for text-only labels)SwingConstants.TRAILING
-
-
Method Detail
-
installInAllColumns
public static void installInAllColumns(JTable table, int alignment)
Installs alignment decorators in all of the table's columns.- Parameters:
table
- a table.alignment
- one of the following constants:SwingConstants.LEFT
SwingConstants.CENTER
(the default for image-only labels)SwingConstants.RIGHT
SwingConstants.LEADING
(the default for text-only labels)SwingConstants.TRAILING
-
installInOneColumn
public static void installInOneColumn(JTable table, int colViewIndex, int alignment)
Installs alignment decorators in the table column atcolViewIndex
.- Parameters:
table
- a table.colViewIndex
- the index of the column in the table view.alignment
- one of the following constants:SwingConstants.LEFT
SwingConstants.CENTER
(the default for image-only labels)SwingConstants.RIGHT
SwingConstants.LEADING
(the default for text-only labels)SwingConstants.TRAILING
-
columnAdded
public void columnAdded(TableColumnModelEvent e)
- Specified by:
columnAdded
in interfaceTableColumnModelListener
-
columnRemoved
public void columnRemoved(TableColumnModelEvent e)
- Specified by:
columnRemoved
in interfaceTableColumnModelListener
-
columnMoved
public void columnMoved(TableColumnModelEvent e)
- Specified by:
columnMoved
in interfaceTableColumnModelListener
-
columnMarginChanged
public void columnMarginChanged(ChangeEvent e)
- Specified by:
columnMarginChanged
in interfaceTableColumnModelListener
-
columnSelectionChanged
public void columnSelectionChanged(ListSelectionEvent e)
- Specified by:
columnSelectionChanged
in interfaceTableColumnModelListener
-
-