Groovy Documentation

com.wordpress.tipsforjava.swing.table
[Java] Class ButtonColumn

java.lang.Object
  javax.swing.AbstractCellEditor
      com.wordpress.tipsforjava.swing.table.ButtonColumn
All Implemented Interfaces:
TableCellRenderer, TableCellEditor, ActionListener, MouseListener

public class ButtonColumn
extends AbstractCellEditor

The ButtonColumn class provides a renderer and an editor that looks like a JButton. The renderer and editor will then be used for a specified column in the table. The TableModel will contain the String to be displayed on the button. The button can be invoked by a mouse click or by pressing the space bar when the cell has focus. Optionaly a mnemonic can be set to invoke the button. When the button is invoked the provided Action is invoked. The source of the Action will be the table. The action command will contain the model row number of the button that was clicked.

Authors:
Rob Camick
Darryl Burke


Field Summary
private Action action

private JButton editButton

private Border focusBorder

private boolean isButtonColumnEditor

private int mnemonic

private Border originalBorder

private JButton renderButton

private JTable table

private String text

 
Constructor Summary
ButtonColumn(JTable table, Action action, int column)

Create the ButtonColumn to be used as a renderer and editor.

 
Method Summary
void actionPerformed(ActionEvent e)

Object getCellEditorValue()

Border getFocusBorder()

Get foreground color of the button when the cell has focus

int getMnemonic()

Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)

Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)

void mouseClicked(MouseEvent e)

void mouseEntered(MouseEvent e)

void mouseExited(MouseEvent e)

void mousePressed(MouseEvent e)

void mouseReleased(MouseEvent e)

void setFocusBorder(Border focusBorder)

The foreground color of the button when the cell has focus

void setMnemonic(int mnemonic)

The mnemonic to activate the button when the cell has focus

 
Methods inherited from class AbstractCellEditor
isCellEditable, stopCellEditing, addCellEditorListener, cancelCellEditing, removeCellEditorListener, shouldSelectCell, getCellEditorListeners, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll, getCellEditorValue
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

action

private Action action


editButton

private JButton editButton


focusBorder

private Border focusBorder


isButtonColumnEditor

private boolean isButtonColumnEditor


mnemonic

private int mnemonic


originalBorder

private Border originalBorder


renderButton

private JButton renderButton


table

private JTable table


text

private String text


 
Constructor Detail

ButtonColumn

public ButtonColumn(JTable table, Action action, int column)
Create the ButtonColumn to be used as a renderer and editor. The renderer and editor will automatically be installed on the TableColumn of the specified column.
Parameters:
table - the table containing the button renderer/editor
action - the Action to be invoked when the button is invoked
column - the column to which the button renderer/editor is added


 
Method Detail

actionPerformed

public void actionPerformed(ActionEvent e)


getCellEditorValue

de
	public
public Object getCellEditorValue()


getFocusBorder

public Border getFocusBorder()
Get foreground color of the button when the cell has focus
Returns:
the foreground color


getMnemonic

public int getMnemonic()


getTableCellEditorComponent

de
	public
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)


getTableCellRendererComponent

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)


mouseClicked

public void mouseClicked(MouseEvent e)


mouseEntered

public void mouseEntered(MouseEvent e)


mouseExited

public void mouseExited(MouseEvent e)


mousePressed

public void mousePressed(MouseEvent e)


mouseReleased

public void mouseReleased(MouseEvent e)


setFocusBorder

public void setFocusBorder(Border focusBorder)
The foreground color of the button when the cell has focus
Parameters:
focusBorder - the foreground color


setMnemonic

public void setMnemonic(int mnemonic)
The mnemonic to activate the button when the cell has focus
Parameters:
mnemonic - the mnemonic


 

Groovy Documentation