Package jmri.util.table
Class ToggleButtonEditor
- java.lang.Object
-
- jmri.util.table.BasicCellEditor
-
- jmri.util.table.ToggleButtonEditor
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.MouseListener
,java.beans.PropertyChangeListener
,java.util.EventListener
,javax.swing.CellEditor
,javax.swing.table.TableCellEditor
public class ToggleButtonEditor extends BasicCellEditor implements java.awt.event.ActionListener, javax.swing.table.TableCellEditor, java.awt.event.MouseListener
Make a JToggleButton in a table cell function. Used eg. in OBlock tables for unitsWorks with
ToggleButtonRenderer
.Adapted from
ButtonRenderer
This also now implements and registers as a MouseListener, so you can change the mouse-event behavior by overriding the needed methods.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Color
background
protected java.awt.Font
font
protected java.awt.Color
foreground
protected java.lang.String
offText
protected java.lang.String
onText
protected java.lang.Object
value
-
Fields inherited from class jmri.util.table.BasicCellEditor
changeEvent, editingEvent, editor, listeners
-
-
Constructor Summary
Constructors Constructor Description ToggleButtonEditor(javax.swing.JToggleButton button, java.lang.String on, java.lang.String off)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent evt)
void
editingStarted(java.util.EventObject event)
java.lang.Object
getCellEditorValue()
java.awt.Component
getTableCellEditorComponent(javax.swing.JTable tbl, java.lang.Object value, boolean isSelected, int row, int column)
void
mouseClicked(java.awt.event.MouseEvent e)
void
mouseEntered(java.awt.event.MouseEvent e)
void
mouseExited(java.awt.event.MouseEvent e)
void
mousePressed(java.awt.event.MouseEvent e)
void
mouseReleased(java.awt.event.MouseEvent e)
void
setBackground(java.awt.Color background)
void
setFont(java.awt.Font font)
void
setForeground(java.awt.Color foreground)
protected void
setValue(java.lang.Object value, java.lang.Boolean sel)
-
Methods inherited from class jmri.util.table.BasicCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getComponent, getEditingEvent, isCellEditable, propertyChange, removeCellEditorListener, setComponent, shouldSelectCell, stopCellEditing
-
-
-
-
Field Detail
-
onText
protected java.lang.String onText
-
offText
protected java.lang.String offText
-
value
protected java.lang.Object value
-
foreground
protected java.awt.Color foreground
-
background
protected java.awt.Color background
-
font
protected java.awt.Font font
-
-
Constructor Detail
-
ToggleButtonEditor
public ToggleButtonEditor(javax.swing.JToggleButton button, java.lang.String on, java.lang.String off)
-
-
Method Detail
-
setForeground
public void setForeground(java.awt.Color foreground)
-
setBackground
public void setBackground(java.awt.Color background)
-
setFont
public void setFont(java.awt.Font font)
-
getCellEditorValue
public java.lang.Object getCellEditorValue()
- Specified by:
getCellEditorValue
in interfacejavax.swing.CellEditor
- Overrides:
getCellEditorValue
in classBasicCellEditor
-
editingStarted
public void editingStarted(java.util.EventObject event)
- Overrides:
editingStarted
in classBasicCellEditor
-
getTableCellEditorComponent
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable tbl, java.lang.Object value, boolean isSelected, int row, int column)
- Specified by:
getTableCellEditorComponent
in interfacejavax.swing.table.TableCellEditor
-
setValue
protected void setValue(java.lang.Object value, java.lang.Boolean sel)
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent evt)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExited
in interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEntered
in interfacejava.awt.event.MouseListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClicked
in interfacejava.awt.event.MouseListener
-
-