Package jmri.util.table
Class ButtonEditor
- java.lang.Object
-
- jmri.util.table.BasicCellEditor
-
- jmri.util.table.ButtonEditor
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.beans.PropertyChangeListener
,java.util.EventListener
,javax.swing.CellEditor
,javax.swing.table.TableCellEditor
,JmriMouseListener
public class ButtonEditor extends BasicCellEditor implements java.awt.event.ActionListener, javax.swing.table.TableCellEditor, JmriMouseListener
Make a JButton in a table cell function.Works with
ButtonRenderer
.This was adapted from Core Swing Advanced Programming, Prentice Hall
Changes: Remove DataWithIcon reference. Change package
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.Object
value
-
Fields inherited from class jmri.util.table.BasicCellEditor
changeEvent, editingEvent, editor, listeners
-
-
Constructor Summary
Constructors Constructor Description ButtonEditor(javax.swing.JButton button)
-
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(JmriMouseEvent e)
Invoked when the mouse button has been clicked (pressed and released) on a component.void
mouseEntered(JmriMouseEvent e)
Invoked when the mouse enters a component.void
mouseExited(JmriMouseEvent e)
Invoked when the mouse exits a component.void
mousePressed(JmriMouseEvent e)
Invoked when a mouse button has been pressed on a component.void
mouseReleased(JmriMouseEvent e)
Invoked when a mouse button has been released on a component.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)
-
Methods inherited from class jmri.util.table.BasicCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getComponent, getEditingEvent, isCellEditable, propertyChange, removeCellEditorListener, setComponent, shouldSelectCell, stopCellEditing
-
-
-
-
Field Detail
-
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
-
ButtonEditor
public ButtonEditor(javax.swing.JButton button)
-
-
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)
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent evt)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
mousePressed
public void mousePressed(JmriMouseEvent e)
Description copied from interface:JmriMouseListener
Invoked when a mouse button has been pressed on a component.- Specified by:
mousePressed
in interfaceJmriMouseListener
- Parameters:
e
- the event to be processed
-
mouseExited
public void mouseExited(JmriMouseEvent e)
Description copied from interface:JmriMouseListener
Invoked when the mouse exits a component.- Specified by:
mouseExited
in interfaceJmriMouseListener
- Parameters:
e
- the event to be processed
-
mouseEntered
public void mouseEntered(JmriMouseEvent e)
Description copied from interface:JmriMouseListener
Invoked when the mouse enters a component.- Specified by:
mouseEntered
in interfaceJmriMouseListener
- Parameters:
e
- the event to be processed
-
mouseReleased
public void mouseReleased(JmriMouseEvent e)
Description copied from interface:JmriMouseListener
Invoked when a mouse button has been released on a component.- Specified by:
mouseReleased
in interfaceJmriMouseListener
- Parameters:
e
- the event to be processed
-
mouseClicked
public void mouseClicked(JmriMouseEvent e)
Description copied from interface:JmriMouseListener
Invoked when the mouse button has been clicked (pressed and released) on a component.- Specified by:
mouseClicked
in interfaceJmriMouseListener
- Parameters:
e
- the event to be processed
-
-