public class SortButtonRenderer
extends java.lang.Object
implements javax.swing.table.TableCellRenderer
This class (and also BevelArrowIcon) is adapted from original code by Nobuo Tamemasa (version 1.0, 26-Feb-1999) posted on www.codeguru.com.
Modifier and Type | Field and Description |
---|---|
private javax.swing.JButton |
ascendingButton
The three buttons that are used to render the table header cells.
|
private javax.swing.JLabel |
ascendingLabel
The ascending label (only used with MacOSX).
|
private javax.swing.JButton |
descendingButton
The three buttons that are used to render the table header cells.
|
private javax.swing.JLabel |
descendingLabel
The descending label (only used with MacOSX).
|
static int |
DOWN
Useful constant indicating ASCENDING (that is, arrow pointing down) sorting in the table.
|
static int |
NONE
Useful constant indicating NO sorting.
|
private javax.swing.JButton |
normalButton
The three buttons that are used to render the table header cells.
|
private javax.swing.JLabel |
normalLabel
The normal label (only used with MacOSX).
|
private int |
pressedColumn
The current pressed column (-1 for no column).
|
static int |
UP
Useful constant indicating DESCENDING (that is, arrow pointing up) sorting in the table.
|
private boolean |
useLabels
Used to allow the class to work out whether to use the buttuns
or labels.
|
Constructor and Description |
---|
SortButtonRenderer()
Creates a new button renderer.
|
Modifier and Type | Method and Description |
---|---|
private javax.swing.JButton |
getRendererButton(boolean isSorting,
boolean isAscending)
Returns the correct button component.
|
private javax.swing.JLabel |
getRendererLabel(boolean isSorting,
boolean isAscending)
Returns the correct label component.
|
java.awt.Component |
getTableCellRendererComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
Returns the renderer component.
|
void |
setPressedColumn(int column)
Sets the pressed column.
|
public static final int NONE
public static final int DOWN
public static final int UP
private int pressedColumn
private javax.swing.JButton normalButton
private javax.swing.JButton ascendingButton
private javax.swing.JButton descendingButton
private boolean useLabels
private javax.swing.JLabel normalLabel
private javax.swing.JLabel ascendingLabel
private javax.swing.JLabel descendingLabel
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)
getTableCellRendererComponent
in interface javax.swing.table.TableCellRenderer
table
- the table.value
- the value.isSelected
- selected?hasFocus
- focussed?row
- the row.column
- the column.private javax.swing.JButton getRendererButton(boolean isSorting, boolean isAscending)
isSorting
- whether the render component represents the sort column.isAscending
- whether the model is ascending.private javax.swing.JLabel getRendererLabel(boolean isSorting, boolean isAscending)
isSorting
- whether the render component represents the sort column.isAscending
- whether the model is ascending.public void setPressedColumn(int column)
column
- the column.