Class TableColumnSizer
- java.lang.Object
-
- org.omegat.util.gui.TableColumnSizer
-
public final class TableColumnSizer extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumnAdjustmentListener(java.awt.event.ActionListener listener)
void
adjustTableColumns()
Adjust the columns of the table.static TableColumnSizer
autoSize(javax.swing.JTable table, int remainderColumn, boolean fitTableToWidth)
Automatically optimize the column widths of a table.void
removeColumnAdjustmentListener(java.awt.event.ActionListener listener)
void
reset()
Reset any state that relies on the contents of the table.void
setRestoreAutoSizing()
-
-
-
Method Detail
-
autoSize
public static TableColumnSizer autoSize(javax.swing.JTable table, int remainderColumn, boolean fitTableToWidth)
Automatically optimize the column widths of a table. TheremainderColumn
is the index of the column that will receive additional space left over after all other columns have been optimally sized. Usually this should be the largest column in the table.When
fitTableToWidth
is false:All columns will be optimally sized all the time (except the
remainderColumn
which may be larger) even if the table then exceeds its parent's width.When
fitTableToWidth
is true:Columns will only be optimized if doing so results in the
remainderColumn
receiving more space than it would underJTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS
- resizing. Resizing behavior will fall back toJTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS
under some threshold below which the latter is better.The result of this is that when widening the table, after the threshold the columns will snap into their optimal size and all additional space goes to the
remainderColumn
.Also note that automatic sizing will be disabled if the user manually adjusts column widths.
- Parameters:
table
-remainderColumn
-fitTableToWidth
-- Returns:
-
reset
public void reset()
Reset any state that relies on the contents of the table.
-
setRestoreAutoSizing
public void setRestoreAutoSizing()
-
adjustTableColumns
public void adjustTableColumns()
Adjust the columns of the table. If possible, this optimally sizes the columns such that columns greater than 0 are only as big as necessary, and the rest of the space goes to column 0. This auto-sizing only happens if it represents an improvement over the default sizing (gives more space to theremainderColumn
than it would get withJTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS
), and only if the user has not manually adjusted column widths.
-
addColumnAdjustmentListener
public void addColumnAdjustmentListener(java.awt.event.ActionListener listener)
-
removeColumnAdjustmentListener
public void removeColumnAdjustmentListener(java.awt.event.ActionListener listener)
-
-