com.explodingpixels.widgets
public class TableHeaderUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
NO_COLUMN |
Modifier and Type | Method and Description |
---|---|
static JComponent |
createCornerComponent(JTable table)
Creates a component that paints the table's header background.
|
static int |
getPressedColumn(JTableHeader tableHeader)
Get's the pressed column header for the given
JTableHeader . |
static int |
getSelectedColumn(JTableHeader tableHeader)
Get's the selected column header for the given
JTableHeader . |
static TableUtils.SortDirection |
getSortDirection(JTableHeader tableHeader,
int columnModelIndex)
Get's the pressed column header for the given
JTableHeader . |
static boolean |
isColumnPressed(JTableHeader tableHeader,
int columnModelIndex)
true if the given column model index is pressed in the given JTableHeader . |
static boolean |
isColumnSelected(JTableHeader tableHeader,
int columnModelIndex)
true if the given column model index is selected in the given JTableHeader . |
static void |
makeHeaderFillEmptySpace(JTable table)
Installs a custom
Border on the given table's JTableHeader that paints any
blank area to the right of the last column header with the JTableHeader 's background. |
static void |
paintHeader(Graphics graphics,
JTable table,
int x,
int width)
Paints the given JTable's table default header background at given
x for the given width.
|
static void |
setPressedColumn(JTableHeader tableHeader,
int columnModelIndex)
Sets the given column for the given
JTableHeader as pressed. |
static TableUtils.SortDirection |
toggleSortDirection(JTableHeader tableHeader,
int columnModelIndex)
Toggles the sort direction of the given column model index in the given
JTableHeader . |
public static final int NO_COLUMN
public static JComponent createCornerComponent(JTable table)
table
- the JTable
to create the corner component for.JComponent
that paints the given table's table header background.public static void makeHeaderFillEmptySpace(JTable table)
Border
on the given table's JTableHeader
that paints any
blank area to the right of the last column header with the JTableHeader
's background.table
- the JTable
from which to get the JTableHeader
to paint the
empty column header space for.public static void paintHeader(Graphics graphics, JTable table, int x, int width)
graphics
- the Graphics
to paint into.table
- the table that the header belongs to.x
- the x coordinate of the table header.width
- the width of the table header.public static int getPressedColumn(JTableHeader tableHeader)
JTableHeader
.tableHeader
- the JTableHeader
to determine the pressed column header for.NO_COLUMN
if no
column's header has been pressed.isColumnPressed(javax.swing.table.JTableHeader, int)
public static boolean isColumnPressed(JTableHeader tableHeader, int columnModelIndex)
true
if the given column model index is pressed in the given JTableHeader
.tableHeader
- the JTableHeader
to use when determining if the given column is
pressed.columnModelIndex
- the column model index to determine the pressed state of.true
if the given column is pressed.getPressedColumn(javax.swing.table.JTableHeader)
,
setPressedColumn(javax.swing.table.JTableHeader, int)
public static void setPressedColumn(JTableHeader tableHeader, int columnModelIndex)
JTableHeader
as pressed. Calling this method
installs a hint, which can be used by renders to draw the correct column pressed state.
Renders can use isColumnPressed(javax.swing.table.JTableHeader, int)
to determine
what state to draw the header for the given index in.
header state.tableHeader
- the JTableHeader
to set the pressed state for.columnModelIndex
- the column model index of the pressed column.public static int getSelectedColumn(JTableHeader tableHeader)
JTableHeader
.tableHeader
- the JTableHeader
to determine the selected column header for.NO_COLUMN
if no
column's header has been pressed.isColumnSelected(javax.swing.table.JTableHeader, int)
public static boolean isColumnSelected(JTableHeader tableHeader, int columnModelIndex)
true
if the given column model index is selected in the given JTableHeader
.
Note that there is no direct way to set wheter a column is selected or not. Selection is a
by-product of set the sort direction on a column.tableHeader
- the JTableHeader
to use when determining if the given column is
selected.columnModelIndex
- the column model index to determine the selected state of.true
if the given column is selected.getSelectedColumn(javax.swing.table.JTableHeader)
,
setSortDirection(javax.swing.table.JTableHeader, int, com.explodingpixels.widgets.TableUtils.SortDirection)
public static TableUtils.SortDirection getSortDirection(JTableHeader tableHeader, int columnModelIndex)
JTableHeader
.tableHeader
- the JTableHeader
containing the column to determine the sort
direction for.columnModelIndex
- the column model index to determine the sort direction for.TableUtils.SortDirection
of the given
column index.setSortDirection(javax.swing.table.JTableHeader, int, com.explodingpixels.widgets.TableUtils.SortDirection)
,
toggleSortDirection(javax.swing.table.JTableHeader, int)
public static TableUtils.SortDirection toggleSortDirection(JTableHeader tableHeader, int columnModelIndex)
JTableHeader
.
This also makes the given column selected. If the given column has no sort order set
(TableUtils.SortDirection.NONE
) then the new sort order
will be TableUtils.SortDirection.ASCENDING
. Otherwise
the new sort order will be TableUtils.SortDirection.DESCENDING
tableHeader
- the JTableHeader
of the column to toggle the sort order for.columnModelIndex
- the column model index to toggle the sort order for.