org.jfree.ui
Class SortableTableHeaderListener

java.lang.Object
  extended by org.jfree.ui.SortableTableHeaderListener
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener

public class SortableTableHeaderListener
extends java.lang.Object
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Captures mouse clicks on a table header, with the intention of triggering a sort. Adapted from code by Nabuo Tamemasa posted on http://www.codeguru.com.

Author:
Nabuo Tamemasa

Constructor Summary
SortableTableHeaderListener(SortableTableModel model, SortButtonRenderer renderer)
          Standard constructor.
 
Method Summary
 void mouseClicked(java.awt.event.MouseEvent e)
          This event is ignored (not required).
 void mouseDragged(java.awt.event.MouseEvent e)
          If the user is dragging or resizing, then we clear the sort column.
 void mouseEntered(java.awt.event.MouseEvent e)
          This event is ignored (not required).
 void mouseExited(java.awt.event.MouseEvent e)
          This event is ignored (not required).
 void mouseMoved(java.awt.event.MouseEvent e)
          This event is ignored (not required).
 void mousePressed(java.awt.event.MouseEvent e)
          Handle a mouse press event - if the user is NOT resizing a column and NOT dragging a column then give visual feedback that the column header has been pressed.
 void mouseReleased(java.awt.event.MouseEvent e)
          When the user releases the mouse button, we attempt to sort the table.
 void setTableModel(SortableTableModel model)
          Sets the table model for the listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortableTableHeaderListener

public SortableTableHeaderListener(SortableTableModel model,
                                   SortButtonRenderer renderer)
Standard constructor.

Parameters:
model - the model.
renderer - the renderer.
Method Detail

setTableModel

public void setTableModel(SortableTableModel model)
Sets the table model for the listener.

Parameters:
model - the model.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Handle a mouse press event - if the user is NOT resizing a column and NOT dragging a column then give visual feedback that the column header has been pressed.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - the mouse event.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
If the user is dragging or resizing, then we clear the sort column.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - the mouse event.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
This event is ignored (not required).

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - the mouse event.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
This event is ignored (not required).

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - the mouse event.

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
This event is ignored (not required).

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e - the mouse event.

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
This event is ignored (not required).

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - the mouse event.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
When the user releases the mouse button, we attempt to sort the table.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - the mouse event.