Package org.openstreetmap.josm.gui.util
Class TableHelper
- java.lang.Object
-
- org.openstreetmap.josm.gui.util.TableHelper
-
public final class TableHelper extends java.lang.Object
The class that provide common JTable customization methods- Since:
- 5785
-
-
Constructor Summary
Constructors Modifier Constructor Description privateTableHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidadaptTo(IEnabledStateUpdating listener, javax.swing.ListSelectionModel listSelectionModel)WireslistenertolistSelectionModelin such a way, thatlistenerreceives aIEnabledStateUpdating.updateEnabledState()on everyListSelectionEvent.static voidadaptTo(IEnabledStateUpdating listener, javax.swing.table.AbstractTableModel listModel)WireslistenertolistModelin such a way, thatlistenerreceives aIEnabledStateUpdating.updateEnabledState()on everyListDataEvent.static voidadjustColumnWidth(javax.swing.JTable tbl, int col, boolean resizable)adjust the preferred width of column col to the maximum preferred width of the cells (including header)static voidadjustColumnWidth(javax.swing.JTable tbl, int col, int maxColumnWidth)adjust the preferred width of column col to the maximum preferred width of the cells (including header) requires JTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);static voidcomputeColumnsWidth(javax.swing.JTable tbl)adjust the table's columns to fit their content best requires JTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);(package private) static intgetColumnHeaderWidth(javax.swing.JTable tbl, int col)(package private) static intgetMaxWidth(javax.swing.JTable tbl, int col)static java.util.stream.IntStreamselectedIndices(javax.swing.ListSelectionModel selectionModel)Returns a stream of all of the selected indices in the selection model, in increasing order.static voidsetFont(javax.swing.JTable table, java.lang.Class<? extends java.awt.Component> parent)Sets the table font size based on the font scaling from the preferencesstatic voidsetSelectedIndices(javax.swing.ListSelectionModel selectionModel, java.util.stream.IntStream indices)Selects the given indices in the selection model
-
-
-
Constructor Detail
-
TableHelper
private TableHelper()
-
-
Method Detail
-
adaptTo
public static void adaptTo(IEnabledStateUpdating listener, javax.swing.ListSelectionModel listSelectionModel)
WireslistenertolistSelectionModelin such a way, thatlistenerreceives aIEnabledStateUpdating.updateEnabledState()on everyListSelectionEvent.- Parameters:
listener- the listenerlistSelectionModel- the source emittingListSelectionEvents- Since:
- 15226
-
adaptTo
public static void adaptTo(IEnabledStateUpdating listener, javax.swing.table.AbstractTableModel listModel)
WireslistenertolistModelin such a way, thatlistenerreceives aIEnabledStateUpdating.updateEnabledState()on everyListDataEvent.- Parameters:
listener- the listenerlistModel- the source emittingListDataEvents- Since:
- 15226
-
getColumnHeaderWidth
static int getColumnHeaderWidth(javax.swing.JTable tbl, int col)
-
getMaxWidth
static int getMaxWidth(javax.swing.JTable tbl, int col)
-
adjustColumnWidth
public static void adjustColumnWidth(javax.swing.JTable tbl, int col, boolean resizable)
adjust the preferred width of column col to the maximum preferred width of the cells (including header)- Parameters:
tbl- tablecol- column indexresizable- if true, resizing is allowed- Since:
- 15176
-
adjustColumnWidth
public static void adjustColumnWidth(javax.swing.JTable tbl, int col, int maxColumnWidth)
adjust the preferred width of column col to the maximum preferred width of the cells (including header) requires JTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);- Parameters:
tbl- tablecol- column indexmaxColumnWidth- maximum column width
-
computeColumnsWidth
public static void computeColumnsWidth(javax.swing.JTable tbl)
adjust the table's columns to fit their content best requires JTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);- Parameters:
tbl- table- Since:
- 14476
-
selectedIndices
public static java.util.stream.IntStream selectedIndices(javax.swing.ListSelectionModel selectionModel)
Returns a stream of all of the selected indices in the selection model, in increasing order.- Parameters:
selectionModel- list selection model.- Returns:
- all of the selected indices, in increasing order, or an empty stream if nothing is selected
- Since:
- 17773
-
setSelectedIndices
public static void setSelectedIndices(javax.swing.ListSelectionModel selectionModel, java.util.stream.IntStream indices)
Selects the given indices in the selection model- Parameters:
selectionModel- list selection model.indices- the indices to select- Since:
- 16601
- See Also:
ListSelectionModel.addSelectionInterval(int, int)
-
setFont
public static void setFont(javax.swing.JTable table, java.lang.Class<? extends java.awt.Component> parent)
Sets the table font size based on the font scaling from the preferences- Parameters:
table- the tableparent- the parent component used for determining the preference key- See Also:
JComponent.setFont(Font),JTable.setRowHeight(int)
-
-