be.ugent.caagt.swirl.tables

Class TableColumnButton

Implemented Interfaces:
Cloneable, TableColumnDecoration

public class TableColumnButton
extends java.lang.Object
implements TableColumnDecoration, 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(Icon icon, Icon iconRollover, Icon iconSelected)
Create a button with given icons.

Method Summary

void
addActionListener(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()
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(Component c, Graphics g, int x, int y)
Paint this decoration.
void
removeActionListener(ActionListener l)
Removes an ActionListener from the button and all its clones.
void
setActionCommand(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.
String
toString()

Constructor Details

TableColumnButton

public TableColumnButton(Icon icon,
                         Icon iconRollover,
                         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 Details

addActionListener

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

copy

public TableColumnButton copy()
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

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.

fireActionPerformed

protected void fireActionPerformed()

getActionCommand

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

getColumnIndex

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

getDecorationHeight

public int getDecorationHeight()
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()
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

mouseEntered

public void mouseEntered()
Signals that the mouse pointer entered the bounds of this decoration.
Specified by:
mouseEntered in interface TableColumnDecoration

mouseExited

public void mouseExited()
Signals that the mouse pointer exited the bounds of this decoration.
Specified by:
mouseExited in interface TableColumnDecoration

mousePressed

public void mousePressed()
Signals that the mouse button was pressed inside the bounds of this decoration.
Specified by:
mousePressed in interface TableColumnDecoration

mouseReleased

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

paintDecoration

public void paintDecoration(Component c,
                            Graphics g,
                            int x,
                            int y)
Paint this decoration.
Specified by:
paintDecoration in interface TableColumnDecoration

removeActionListener

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

setActionCommand

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

setColumnIndex

public void setColumnIndex(int columnIndex)
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.

toString

public String toString()