jmri.util.table
Class ButtonEditor

java.lang.Object
  extended by jmri.util.table.BasicCellEditor
      extended by jmri.util.table.ButtonEditor
All Implemented Interfaces:
ActionListener, MouseListener, PropertyChangeListener, EventListener, CellEditor, TableCellEditor

public class ButtonEditor
extends BasicCellEditor
implements ActionListener, TableCellEditor, MouseListener

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
protected  Color background
           
protected  Font font
           
protected  Color foreground
           
protected  Object value
           
 
Fields inherited from class jmri.util.table.BasicCellEditor
editingEvent, editor, listeners
 
Constructor Summary
ButtonEditor(JButton button)
           
 
Method Summary
 void actionPerformed(ActionEvent evt)
           
 void editingStarted(EventObject event)
           
 Object getCellEditorValue()
           
 Component getTableCellEditorComponent(JTable tbl, Object value, boolean isSelected, 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 setBackground(Color background)
           
 void setFont(Font font)
           
 void setForeground(Color foreground)
           
protected  void setValue(Object value)
           
 
Methods inherited from class jmri.util.table.BasicCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getComponent, getEditingEvent, isCellEditable, propertyChange, removeCellEditorListener, setComponent, 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
 

Field Detail

value

protected Object value

foreground

protected Color foreground

background

protected Color background

font

protected Font font
Constructor Detail

ButtonEditor

public ButtonEditor(JButton button)
Method Detail

setForeground

public void setForeground(Color foreground)

setBackground

public void setBackground(Color background)

setFont

public void setFont(Font font)

getCellEditorValue

public Object getCellEditorValue()
Specified by:
getCellEditorValue in interface CellEditor
Overrides:
getCellEditorValue in class BasicCellEditor

editingStarted

public void editingStarted(EventObject event)
Overrides:
editingStarted in class BasicCellEditor

getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable tbl,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
Specified by:
getTableCellEditorComponent in interface TableCellEditor

setValue

protected void setValue(Object value)

actionPerformed

public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads