Class ButtonColumn
java.lang.Object
javax.swing.AbstractCellEditor
com.illumon.iris.console.utils.input.ButtonColumn
- All Implemented Interfaces:
ActionListener
,MouseListener
,Serializable
,EventListener
,CellEditor
,TableCellEditor
,TableCellRenderer
public class ButtonColumn extends AbstractCellEditor implements TableCellRenderer, TableCellEditor, ActionListener, MouseListener
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. Optionally 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.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ButtonColumn.ButtonDetails
Class to allow creating buttons that have some non-standard properties (e.g., tooltips, disabled) instead of just buttons with text. -
Field Summary
-
Constructor Summary
Constructors Constructor Description ButtonColumn(JTable table, Action action, int column, TableCellRenderer emptyRenderer)
Create the ButtonColumn to be used as a renderer and editor. -
Method Summary
Modifier and Type Method Description void
actionPerformed(ActionEvent e)
static ButtonColumn.ButtonDetails
details(String text)
Object
getCellEditorValue()
Border
getFocusBorder()
Get foreground color of the button when the cell has focusint
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 focusvoid
setMnemonic(int mnemonic)
The mnemonic to activate the button when the cell has focusMethods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
-
Constructor Details
-
ButtonColumn
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/editoraction
- the Action to be invoked when the button is invokedcolumn
- the column to which the button renderer/editor is addedemptyRenderer
- the renderer to use for null values
-
-
Method Details
-
details
-
getFocusBorder
Get foreground color of the button when the cell has focus- Returns:
- the foreground color
-
setFocusBorder
The foreground color of the button when the cell has focus- Parameters:
focusBorder
- the foreground color
-
getMnemonic
public int getMnemonic() -
setMnemonic
public void setMnemonic(int mnemonic)The mnemonic to activate the button when the cell has focus- Parameters:
mnemonic
- the mnemonic
-
getTableCellEditorComponent
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)- Specified by:
getTableCellEditorComponent
in interfaceTableCellEditor
-
getCellEditorValue
- Specified by:
getCellEditorValue
in interfaceCellEditor
-
getTableCellRendererComponent
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)- Specified by:
getTableCellRendererComponent
in interfaceTableCellRenderer
-
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-