Package org.jfree.ui
Class SortButtonRenderer
- java.lang.Object
-
- org.jfree.ui.SortButtonRenderer
-
- All Implemented Interfaces:
javax.swing.table.TableCellRenderer
public class SortButtonRenderer extends java.lang.Object implements javax.swing.table.TableCellRendererA 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
Fields Modifier and Type Field Description private javax.swing.JButtonascendingButtonThe three buttons that are used to render the table header cells.private javax.swing.JLabelascendingLabelThe ascending label (only used with MacOSX).private javax.swing.JButtondescendingButtonThe three buttons that are used to render the table header cells.private javax.swing.JLabeldescendingLabelThe descending label (only used with MacOSX).static intDOWNUseful constant indicating ASCENDING (that is, arrow pointing down) sorting in the table.static intNONEUseful constant indicating NO sorting.private javax.swing.JButtonnormalButtonThe three buttons that are used to render the table header cells.private javax.swing.JLabelnormalLabelThe normal label (only used with MacOSX).private intpressedColumnThe current pressed column (-1 for no column).static intUPUseful constant indicating DESCENDING (that is, arrow pointing up) sorting in the table.private booleanuseLabelsUsed to allow the class to work out whether to use the buttuns or labels.
-
Constructor Summary
Constructors Constructor Description SortButtonRenderer()Creates a new button renderer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private javax.swing.JButtongetRendererButton(boolean isSorting, boolean isAscending)Returns the correct button component.private javax.swing.JLabelgetRendererLabel(boolean isSorting, boolean isAscending)Returns the correct label component.java.awt.ComponentgetTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)Returns the renderer component.voidsetPressedColumn(int column)Sets the pressed column.
-
-
-
Field Detail
-
NONE
public static final int NONE
Useful constant indicating NO sorting.- See Also:
- Constant Field Values
-
DOWN
public static final int DOWN
Useful constant indicating ASCENDING (that is, arrow pointing down) sorting in the table.- See Also:
- Constant Field Values
-
UP
public static final int UP
Useful constant indicating DESCENDING (that is, arrow pointing up) sorting in the table.- See Also:
- Constant Field Values
-
pressedColumn
private int pressedColumn
The current pressed column (-1 for no column).
-
normalButton
private javax.swing.JButton normalButton
The three buttons that are used to render the table header cells.
-
ascendingButton
private javax.swing.JButton ascendingButton
The three buttons that are used to render the table header cells.
-
descendingButton
private javax.swing.JButton descendingButton
The three buttons that are used to render the table header cells.
-
useLabels
private boolean useLabels
Used 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
private javax.swing.JLabel normalLabel
The normal label (only used with MacOSX).
-
ascendingLabel
private javax.swing.JLabel ascendingLabel
The ascending label (only used with MacOSX).
-
descendingLabel
private javax.swing.JLabel descendingLabel
The descending label (only used with MacOSX).
-
-
Method Detail
-
getTableCellRendererComponent
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)Returns the renderer component.- Specified by:
getTableCellRendererComponentin interfacejavax.swing.table.TableCellRenderer- Parameters:
table- the table.value- the value.isSelected- selected?hasFocus- focussed?row- the row.column- the column.- Returns:
- the renderer.
-
getRendererButton
private javax.swing.JButton getRendererButton(boolean isSorting, boolean isAscending)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
private javax.swing.JLabel getRendererLabel(boolean isSorting, boolean isAscending)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.
-
-