com.sciapp.table
Class SortTableButtonRenderer

java.lang.Object
  extended by com.sciapp.table.SortTableRenderer
      extended by com.sciapp.table.SortTableButtonRenderer
All Implemented Interfaces:
Serializable, TableCellRenderer

public class SortTableButtonRenderer
extends SortTableRenderer

A SortTableRenderer implementation that uses JButtons in order to render the table header. This class shows the column sorting order as a number next to the column name.

See Also:
Serialized Form

Field Summary
protected  boolean showButtonPress
          boolean flag that when true, the buttons are pressed when clicked.
 
Constructor Summary
SortTableButtonRenderer()
          Constructs a SortTableButtonRenderer.
 
Method Summary
 JButton getAscendingButton()
          Returns the button used to render a column sorted in ascending order.
 JButton getDescendingButton()
          Returns the button used to render a column sorted in descending order.
 JButton getNoSortButton()
          Returns the button used to render a non-sortable column.
 boolean getShowButtonPress()
          Returns true if the button should be pressed when clicked.
 Component prepareRenderer(int sortIndex, boolean ascending, int sortSize, boolean isPressed, Object value, int column)
          Prepares and returns the component used for drawing the column header according to the method's arguments.
 void setShowButtonPress(boolean showButtonPress)
          Sets a flag that is true if the button should be pressed when clicked.
 void updateUI()
          Called whenever the UI changes, in order to update the components used to draw the columns of the table header.
 
Methods inherited from class com.sciapp.table.SortTableRenderer
getTableCellRendererComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

showButtonPress

protected boolean showButtonPress
boolean flag that when true, the buttons are pressed when clicked.

Constructor Detail

SortTableButtonRenderer

public SortTableButtonRenderer()
Constructs a SortTableButtonRenderer.

Method Detail

getAscendingButton

public JButton getAscendingButton()
Returns the button used to render a column sorted in ascending order.

Returns:
a button

getDescendingButton

public JButton getDescendingButton()
Returns the button used to render a column sorted in descending order.

Returns:
a button

getNoSortButton

public JButton getNoSortButton()
Returns the button used to render a non-sortable column.

Returns:
a button

getShowButtonPress

public boolean getShowButtonPress()
Returns true if the button should be pressed when clicked.

Returns:
the showButtonPress flag

prepareRenderer

public Component prepareRenderer(int sortIndex,
                                 boolean ascending,
                                 int sortSize,
                                 boolean isPressed,
                                 Object value,
                                 int column)
Prepares and returns the component used for drawing the column header according to the method's arguments.

Specified by:
prepareRenderer in class SortTableRenderer
Parameters:
sortIndex - the sorting order of the column. -1 indicates no sorting.
ascending - flag that is true if ascending sorting is in use, false if descending.
sortSize - the total number of sorting columns.
isPressed - flag that is true if the column is being pressed with the mouse.
value - the value of the header column.
column - the column being drawn.

setShowButtonPress

public void setShowButtonPress(boolean showButtonPress)
Sets a flag that is true if the button should be pressed when clicked.

Parameters:
showButtonPress - the showButtonPress flag

updateUI

public void updateUI()
Called whenever the UI changes, in order to update the components used to draw the columns of the table header.

Specified by:
updateUI in class SortTableRenderer