be.ugent.caagt.swirl.tables
Class TableColumnButton

java.lang.Object
  extended by be.ugent.caagt.swirl.tables.TableColumnButton
All Implemented Interfaces:
TableColumnDecoration, java.lang.Cloneable

public class TableColumnButton
extends java.lang.Object
implements TableColumnDecoration, java.lang.Cloneable

Table column decoration that behaves like a button. Clients may register action listeners with a prototype button which will then fire for every clone made. The action listener can distinguish between clones by the value returned by getColumnIndex().


Constructor Summary
TableColumnButton(javax.swing.Icon icon, javax.swing.Icon iconRollover, javax.swing.Icon iconSelected)
          Create a button with given icons.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
          Adds an ActionListener to the button.
 TableColumnButton copy()
          Makes a copy of this object.
static TableColumnButton createCloseButton()
          Return a button with the look and feel of a 'close' button.
protected  void fireActionPerformed()
           
 java.lang.String getActionCommand()
          Return the action command for this button.
 int getColumnIndex()
          Return the column index for this button.
 int getDecorationHeight()
          Return the height of this decoration.
 int getDecorationWidth()
          Return the width of this decoration.
 void mouseEntered()
          Signals that the mouse pointer entered the bounds of this decoration.
 void mouseExited()
          Signals that the mouse pointer exited the bounds of this decoration.
 void mousePressed()
          Signals that the mouse button was pressed inside the bounds of this decoration.
 void mouseReleased()
          Signals that the mouse button was released after being pressed inside the bounds of this decoration.
 void paintDecoration(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Paint this decoration.
 void removeActionListener(java.awt.event.ActionListener l)
          Removes an ActionListener from the button and all its clones.
 void setActionCommand(java.lang.String actionCommand)
          Set the action command for this button.
 void setColumnIndex(int columnIndex)
          Called to indicate that this decoration has been associated with the given table column.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableColumnButton

public TableColumnButton(javax.swing.Icon icon,
                         javax.swing.Icon iconRollover,
                         javax.swing.Icon iconSelected)
Create a button with given icons. All parameters must have the same dimensions. Parameters cannot be null, but it is allowed for two or three parameters to be identical.

Method Detail

copy

public TableColumnButton copy()
Description copied from interface: TableColumnDecoration
Makes a copy of this object. This is typically implemented as (MyDecoration)super.clone() where MyDecoration is a class that implements this interface, surrounded by a try-catch clause which caches the CloneNotSupportedException.

Specified by:
copy in interface TableColumnDecoration

getActionCommand

public java.lang.String getActionCommand()
Return the action command for this button.


setActionCommand

public void setActionCommand(java.lang.String actionCommand)
Set the action command for this button. An action command set for the prototype will be propagated to all clones.


createCloseButton

public static TableColumnButton createCloseButton()
Return a button with the look and feel of a 'close' button. Convenience method which enables the use of standard icons.


getDecorationHeight

public int getDecorationHeight()
Description copied from interface: TableColumnDecoration
Return the height of this decoration. The dimensions of a decoration determine its position on the column header and the bounds in which mouse events are fired.

Specified by:
getDecorationHeight in interface TableColumnDecoration

getDecorationWidth

public int getDecorationWidth()
Description copied from interface: TableColumnDecoration
Return the width of this decoration. The dimensions of a decoration determine its position on the column header and the bounds in which mouse events are fired.

Specified by:
getDecorationWidth in interface TableColumnDecoration

paintDecoration

public void paintDecoration(java.awt.Component c,
                            java.awt.Graphics g,
                            int x,
                            int y)
Description copied from interface: TableColumnDecoration
Paint this decoration.

Specified by:
paintDecoration in interface TableColumnDecoration

mouseReleased

public void mouseReleased()
Description copied from interface: TableColumnDecoration
Signals that the mouse button was released after being pressed inside the bounds of this decoration.

Specified by:
mouseReleased in interface TableColumnDecoration

mousePressed

public void mousePressed()
Description copied from interface: TableColumnDecoration
Signals that the mouse button was pressed inside the bounds of this decoration.

Specified by:
mousePressed in interface TableColumnDecoration

mouseExited

public void mouseExited()
Description copied from interface: TableColumnDecoration
Signals that the mouse pointer exited the bounds of this decoration.

Specified by:
mouseExited in interface TableColumnDecoration

mouseEntered

public void mouseEntered()
Description copied from interface: TableColumnDecoration
Signals that the mouse pointer entered the bounds of this decoration.

Specified by:
mouseEntered in interface TableColumnDecoration

setColumnIndex

public void setColumnIndex(int columnIndex)
Description copied from interface: TableColumnDecoration
Called to indicate that this decoration has been associated with the given table column.

Specified by:
setColumnIndex in interface TableColumnDecoration
Parameters:
columnIndex - Column index in the data model.

getColumnIndex

public int getColumnIndex()
Return the column index for this button. Only valid for clones, the prototype returns -1.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Adds an ActionListener to the button. Action listeners are shared by all clones.


removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Removes an ActionListener from the button and all its clones.


fireActionPerformed

protected void fireActionPerformed()