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 voidaddColumnAdjustmentListener(java.awt.event.ActionListener listener)voidadjustTableColumns()Adjust the columns of the table.static TableColumnSizerautoSize(javax.swing.JTable table, int remainderColumn, boolean fitTableToWidth)Automatically optimize the column widths of a table.voidremoveColumnAdjustmentListener(java.awt.event.ActionListener listener)voidreset()Reset any state that relies on the contents of the table.voidsetRestoreAutoSizing()
-
-
-
Method Detail
-
autoSize
public static TableColumnSizer autoSize(javax.swing.JTable table, int remainderColumn, boolean fitTableToWidth)
Automatically optimize the column widths of a table. TheremainderColumnis 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
fitTableToWidthis false:All columns will be optimally sized all the time (except the
remainderColumnwhich may be larger) even if the table then exceeds its parent's width.When
fitTableToWidthis true:Columns will only be optimized if doing so results in the
remainderColumnreceiving more space than it would underJTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS- resizing. Resizing behavior will fall back toJTable.AUTO_RESIZE_SUBSEQUENT_COLUMNSunder 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 theremainderColumnthan 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)
-
-