org.gjt.btools.gui.component
Class CheckBoxRenderer

java.lang.Object
  |
  +--javax.swing.AbstractCellEditor
        |
        +--org.gjt.btools.gui.component.CheckBoxRenderer
All Implemented Interfaces:
javax.swing.CellEditor, java.util.EventListener, java.awt.event.ItemListener, java.io.Serializable, javax.swing.table.TableCellEditor, javax.swing.table.TableCellRenderer

public class CheckBoxRenderer
extends javax.swing.AbstractCellEditor
implements javax.swing.table.TableCellRenderer, javax.swing.table.TableCellEditor, java.awt.event.ItemListener

A checkbox that is used as a boolean table cell. This class can be used as both a cell renderer and a cell editor if desired. The corresponding value in the table must be of type Boolean.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
CheckBoxRenderer()
          Creates a new checkbox renderer/editor.
 
Method Summary
 void cancelCellEditing()
          Cancels editing the table cell and disregards any changes.
 java.lang.Object getCellEditorValue()
          Returns the value contained in the cell editor.
 java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
          Returns the component that does the editing.
 java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)
          Returns the component that does the rendering.
 void itemStateChanged(java.awt.event.ItemEvent e)
          Called when the checkbox has changed state.
 boolean shouldSelectCell(java.util.EventObject e)
          Prepares the component for editing as requested by the given event.
 boolean stopCellEditing()
          Stops editing the table cell and stores any changes.
 
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener
 
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, isCellEditable, removeCellEditorListener
 

Constructor Detail

CheckBoxRenderer

public CheckBoxRenderer()
Creates a new checkbox renderer/editor.

Method Detail

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Called when the checkbox has changed state.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
e - the state changing event.

getTableCellRendererComponent

public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table,
                                                        java.lang.Object value,
                                                        boolean isSelected,
                                                        boolean hasFocus,
                                                        int row,
                                                        int column)
Returns the component that does the rendering.

Specified by:
getTableCellRendererComponent in interface javax.swing.table.TableCellRenderer
Parameters:
table - the table in which a cell is being rendered.
value - the value of the table cell being rendered.
isSelected - whether or not the table cell is currently selected.
hasFocus - whether or not the table cell currently has the focus.
row - the row of the table cell being rendered.
column - the column of the table cell being rendered.
Returns:
the component that does the rendering.

getTableCellEditorComponent

public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table,
                                                      java.lang.Object value,
                                                      boolean isSelected,
                                                      int row,
                                                      int column)
Returns the component that does the editing.

Specified by:
getTableCellEditorComponent in interface javax.swing.table.TableCellEditor
Parameters:
table - the table in which a cell is being edited.
value - the value of the table cell being edited.
isSelected - whether or not the table cell is currently selected.
row - the row of the table cell being edited.
column - the column of the table cell being edited.
Returns:
the component that does the editing.

getCellEditorValue

public java.lang.Object getCellEditorValue()
Returns the value contained in the cell editor.

Specified by:
getCellEditorValue in interface javax.swing.CellEditor
Returns:
the value contained in the cell editor.

shouldSelectCell

public boolean shouldSelectCell(java.util.EventObject e)
Prepares the component for editing as requested by the given event.

Specified by:
shouldSelectCell in interface javax.swing.CellEditor
Overrides:
shouldSelectCell in class javax.swing.AbstractCellEditor
Parameters:
e - the event that caused editing to begin.
Returns:
true if and only if the table cell being edited should be selected.

stopCellEditing

public boolean stopCellEditing()
Stops editing the table cell and stores any changes.

Specified by:
stopCellEditing in interface javax.swing.CellEditor
Overrides:
stopCellEditing in class javax.swing.AbstractCellEditor
Returns:
true if and only if editing was successfully stopped.

cancelCellEditing

public void cancelCellEditing()
Cancels editing the table cell and disregards any changes.

Specified by:
cancelCellEditing in interface javax.swing.CellEditor
Overrides:
cancelCellEditing in class javax.swing.AbstractCellEditor


Copyright © 1998-2001, Ben Burton
This software is released under the GNU Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).