public class TableAligner
extends java.lang.Object
implements javax.swing.event.TableColumnModelListener
JTable
. Expected usage:
JTable table = new JTable(...); TableAligner aligner = new TableAligner(table, SwingConstants.XXXX); table.getColumnModel().addColumnModelListener(aligner);
Constructor and Description |
---|
TableAligner(javax.swing.JTable table,
int alignment)
Creates a listener that installs alignment decorators on new columns added to
table . |
Modifier and Type | Method and Description |
---|---|
void |
columnAdded(javax.swing.event.TableColumnModelEvent e) |
void |
columnMarginChanged(javax.swing.event.ChangeEvent e) |
void |
columnMoved(javax.swing.event.TableColumnModelEvent e) |
void |
columnRemoved(javax.swing.event.TableColumnModelEvent e) |
void |
columnSelectionChanged(javax.swing.event.ListSelectionEvent e) |
static void |
installInAllColumns(javax.swing.JTable table,
int alignment)
Installs alignment decorators in all of the table's columns.
|
static void |
installInOneColumn(javax.swing.JTable table,
int colViewIndex,
int alignment)
Installs alignment decorators in the table column at
colViewIndex . |
public TableAligner(javax.swing.JTable table, int alignment)
table
.
Also performs the initial alignment of table
.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
public static void installInAllColumns(javax.swing.JTable table, int alignment)
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
public static void installInOneColumn(javax.swing.JTable table, int colViewIndex, int alignment)
colViewIndex
.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
public void columnAdded(javax.swing.event.TableColumnModelEvent e)
columnAdded
in interface javax.swing.event.TableColumnModelListener
public void columnRemoved(javax.swing.event.TableColumnModelEvent e)
columnRemoved
in interface javax.swing.event.TableColumnModelListener
public void columnMoved(javax.swing.event.TableColumnModelEvent e)
columnMoved
in interface javax.swing.event.TableColumnModelListener
public void columnMarginChanged(javax.swing.event.ChangeEvent e)
columnMarginChanged
in interface javax.swing.event.TableColumnModelListener
public void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
columnSelectionChanged
in interface javax.swing.event.TableColumnModelListener