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 voidcolumnAdded(TableColumnModelEvent e)voidcolumnMarginChanged(ChangeEvent e)voidcolumnMoved(TableColumnModelEvent e)voidcolumnRemoved(TableColumnModelEvent e)voidcolumnSelectionChanged(ListSelectionEvent e)static voidinstallInAllColumns(JTable table, int alignment)Installs alignment decorators in all of the table's columns.static voidinstallInOneColumn(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.LEFTSwingConstants.CENTER(the default for image-only labels)SwingConstants.RIGHTSwingConstants.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.LEFTSwingConstants.CENTER(the default for image-only labels)SwingConstants.RIGHTSwingConstants.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.LEFTSwingConstants.CENTER(the default for image-only labels)SwingConstants.RIGHTSwingConstants.LEADING(the default for text-only labels)SwingConstants.TRAILING
-
columnAdded
public void columnAdded(TableColumnModelEvent e)
- Specified by:
columnAddedin interfaceTableColumnModelListener
-
columnRemoved
public void columnRemoved(TableColumnModelEvent e)
- Specified by:
columnRemovedin interfaceTableColumnModelListener
-
columnMoved
public void columnMoved(TableColumnModelEvent e)
- Specified by:
columnMovedin interfaceTableColumnModelListener
-
columnMarginChanged
public void columnMarginChanged(ChangeEvent e)
- Specified by:
columnMarginChangedin interfaceTableColumnModelListener
-
columnSelectionChanged
public void columnSelectionChanged(ListSelectionEvent e)
- Specified by:
columnSelectionChangedin interfaceTableColumnModelListener
-
-