|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.AbstractCellEditor | +--org.gjt.btools.gui.component.ButtonRenderer
A button that is used as a table cell. This component is actually implemented both as a cell renderer and a cell editor. Because the user must interact directly with this component, it must be registered both as a renderer and an editor for the appropriate table cells and the table model must declare that such cells be editable, regardless of whether the table contents will ever be changed.
To listen for button presses, you can simply register an action listener with this object; there is no need to access the underlying JButtons. An action event will be fired when the table cell button is pressed, and the corresponding routine that is called (at the listener's end) should end with a call to either stopCellEditing() (to save any changes to the table) or to cancelCellEditing() (to make no changes to the table).
If changes are to be made to the table, routine getCellEditorValue() must be overridden to return a new value for the table cell.
Field Summary |
Fields inherited from class javax.swing.AbstractCellEditor |
changeEvent, listenerList |
Constructor Summary | |
ButtonRenderer(java.lang.String text)
Creates a new button renderer/editor displaying the given text. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
For internal use only. |
void |
addActionListener(java.awt.event.ActionListener l)
Registers the given listener to listen for action events coming from this object. |
int |
getCellEditorColumn()
Returns the column containing the cell editor. |
int |
getCellEditorRow()
Returns the row containing the cell editor. |
java.lang.Object |
getCellEditorValue()
Returns the value contained in the cell editor. |
javax.swing.JButton |
getEditorButton()
Returns the button used for cell editing. |
javax.swing.JButton |
getRendererButton()
Returns the button used for cell rendering. |
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 |
removeActionListener(java.awt.event.ActionListener l)
Unregisters the given listener so it no longer listens for action events coming from this object. |
void |
setBorder(javax.swing.border.Border border)
Sets the border to use for both the rendering and editing buttons. |
void |
setText(java.lang.String text)
Sets the text to display on both the rendering and editing buttons. |
boolean |
shouldSelectCell(java.util.EventObject e)
Prepares the component for editing as requested by the given event. |
Methods inherited from class javax.swing.AbstractCellEditor |
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, 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, stopCellEditing |
Constructor Detail |
public ButtonRenderer(java.lang.String text)
text
- the text to place on the button.Method Detail |
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)
getTableCellRendererComponent
in interface javax.swing.table.TableCellRenderer
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.
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
getTableCellEditorComponent
in interface javax.swing.table.TableCellEditor
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.
public int getCellEditorRow()
public int getCellEditorColumn()
public java.lang.Object getCellEditorValue()
getCellEditorValue
in interface javax.swing.CellEditor
public javax.swing.JButton getRendererButton()
getEditorButton()
public javax.swing.JButton getEditorButton()
getRendererButton()
public void setText(java.lang.String text)
Note that there are two buttons used by this class; one that renders table cells and one that the user interacts with when editing table cells. This routine affects both of these buttons.
text
- the text to display on both buttons.public void setBorder(javax.swing.border.Border border)
Note that there are two buttons used by this class; one that renders table cells and one that the user interacts with when editing table cells. This routine affects both of these buttons.
border
- the border to use for both buttons.public void addActionListener(java.awt.event.ActionListener l)
l
- the listener to add.public void removeActionListener(java.awt.event.ActionListener l)
l
- the listener to remove.public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
e
- the details of the button press event.public boolean shouldSelectCell(java.util.EventObject e)
shouldSelectCell
in interface javax.swing.CellEditor
shouldSelectCell
in class javax.swing.AbstractCellEditor
e
- the event that caused editing to begin.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |