Package com.explodingpixels.widgets
Class TableUtils
java.lang.Object
com.explodingpixels.widgets.TableUtils
A collection of utility methods to be used with
JTable
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
An interface that will be notified when sorting of aJTable
should occur.static enum
An enumeration representing the sort order of a table column. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
makeSortable
(JTable table, TableUtils.SortDelegate sortDelegate) Installs a listener on the givenJTable
'sJTableHeader
, which will notify the givenTableUtils.SortDelegate
when the user clicks the header and thus wishes to sort.static void
makeStriped
(JTable table, Color stipeColor) Add's striping to the background of the givenJTable
.
-
Method Details
-
makeStriped
Add's striping to the background of the givenJTable
. The actual striping is installed on the containingJScrollPane
'sJViewport
, so if this table is not added to aJScrollPane
, then no stripes will be painted. This method can be called before the given table is added to a scroll pane, though, as aPropertyChangeListener
will be installed to handle "ancestor" changes.- Parameters:
table
- the table to paint row stripes for.stipeColor
- the color of the stripes to paint.
-
makeSortable
Installs a listener on the givenJTable
'sJTableHeader
, which will notify the givenTableUtils.SortDelegate
when the user clicks the header and thus wishes to sort. The listener will also callTableHeaderUtils.toggleSortDirection(javax.swing.table.JTableHeader, int)
andTableHeaderUtils.setPressedColumn(javax.swing.table.JTableHeader, int)
which will install hints for header renders to render the column headers in the appropriate state.- Parameters:
table
- the table so install theSortDelegate
on.sortDelegate
- the delegate to notify when sorting should be performed.
-