Package org.jfree.ui
Class SortButtonRenderer
java.lang.Object
org.jfree.ui.SortButtonRenderer
- All Implemented Interfaces:
TableCellRenderer
A table cell renderer for table headings - uses one of three JButton instances to indicate the
sort order for the table column.
This class (and also BevelArrowIcon) is adapted from original code by Nobuo Tamemasa (version 1.0, 26-Feb-1999) posted on www.codeguru.com.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JButtonThe three buttons that are used to render the table header cells.private JLabelThe ascending label (only used with MacOSX).private JButtonThe three buttons that are used to render the table header cells.private JLabelThe descending label (only used with MacOSX).static final intUseful constant indicating ASCENDING (that is, arrow pointing down) sorting in the table.static final intUseful constant indicating NO sorting.private JButtonThe three buttons that are used to render the table header cells.private JLabelThe normal label (only used with MacOSX).private intThe current pressed column (-1 for no column).static final intUseful constant indicating DESCENDING (that is, arrow pointing up) sorting in the table.private booleanUsed to allow the class to work out whether to use the buttuns or labels. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate JButtongetRendererButton(boolean isSorting, boolean isAscending) Returns the correct button component.private JLabelgetRendererLabel(boolean isSorting, boolean isAscending) Returns the correct label component.getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) Returns the renderer component.voidsetPressedColumn(int column) Sets the pressed column.
-
Field Details
-
NONE
public static final int NONEUseful constant indicating NO sorting.- See Also:
-
DOWN
public static final int DOWNUseful constant indicating ASCENDING (that is, arrow pointing down) sorting in the table.- See Also:
-
UP
public static final int UPUseful constant indicating DESCENDING (that is, arrow pointing up) sorting in the table.- See Also:
-
pressedColumn
private int pressedColumnThe current pressed column (-1 for no column). -
normalButton
The three buttons that are used to render the table header cells. -
ascendingButton
The three buttons that are used to render the table header cells. -
descendingButton
The three buttons that are used to render the table header cells. -
useLabels
private boolean useLabelsUsed to allow the class to work out whether to use the buttuns or labels. Labels are required when using the aqua look and feel cos the buttons won't fit. -
normalLabel
The normal label (only used with MacOSX). -
ascendingLabel
The ascending label (only used with MacOSX). -
descendingLabel
The descending label (only used with MacOSX).
-
-
Constructor Details
-
SortButtonRenderer
public SortButtonRenderer()Creates a new button renderer.
-
-
Method Details
-
getTableCellRendererComponent
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) Returns the renderer component.- Specified by:
getTableCellRendererComponentin interfaceTableCellRenderer- Parameters:
table- the table.value- the value.isSelected- selected?hasFocus- focussed?row- the row.column- the column.- Returns:
- the renderer.
-
getRendererButton
Returns the correct button component.- Parameters:
isSorting- whether the render component represents the sort column.isAscending- whether the model is ascending.- Returns:
- either the ascending, descending or normal button.
-
getRendererLabel
Returns the correct label component.- Parameters:
isSorting- whether the render component represents the sort column.isAscending- whether the model is ascending.- Returns:
- either the ascending, descending or normal label.
-
setPressedColumn
public void setPressedColumn(int column) Sets the pressed column.- Parameters:
column- the column.
-