Package org.jfree.ui

Class SortableTableHeaderListener

java.lang.Object
org.jfree.ui.SortableTableHeaderListener
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener

public class SortableTableHeaderListener extends Object implements MouseListener, 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.
  • Field Details

    • model

      private SortableTableModel model
      A reference to the table model.
    • renderer

      private SortButtonRenderer renderer
      The header renderer.
    • sortColumnIndex

      private int sortColumnIndex
      The index of the column that is sorted - used to determine the state of the renderer.
  • Constructor Details

    • SortableTableHeaderListener

      public SortableTableHeaderListener(SortableTableModel model, SortButtonRenderer renderer)
      Standard constructor.
      Parameters:
      model - the model.
      renderer - the renderer.
  • Method Details

    • setTableModel

      public void setTableModel(SortableTableModel model)
      Sets the table model for the listener.
      Parameters:
      model - the model.
    • mousePressed

      public void mousePressed(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 MouseListener
      Parameters:
      e - the mouse event.
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      If the user is dragging or resizing, then we clear the sort column.
      Specified by:
      mouseDragged in interface MouseMotionListener
      Parameters:
      e - the mouse event.
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      This event is ignored (not required).
      Specified by:
      mouseEntered in interface MouseListener
      Parameters:
      e - the mouse event.
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      This event is ignored (not required).
      Specified by:
      mouseClicked in interface MouseListener
      Parameters:
      e - the mouse event.
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      This event is ignored (not required).
      Specified by:
      mouseMoved in interface MouseMotionListener
      Parameters:
      e - the mouse event.
    • mouseExited

      public void mouseExited(MouseEvent e)
      This event is ignored (not required).
      Specified by:
      mouseExited in interface MouseListener
      Parameters:
      e - the mouse event.
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      When the user releases the mouse button, we attempt to sort the table.
      Specified by:
      mouseReleased in interface MouseListener
      Parameters:
      e - the mouse event.