|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.AbstractCellEditor
org.tbee.swing.table.ActionEditorJButton
public class ActionEditorJButton
This class is suited to render a single AbstractAction on multiple row. Usually the action does involve something row-specific, this would mean that you need to provide a separate AbstractAction instance for each row. And each instance must contain all the data it needs to execute it action. Using one instance and updating it upon click does not work because of the random way parts of the table are redrawn. Providing a separate AbstractAction class will work fine with this editor. But this also supports a single instance approach, where the clicked row index is handed over. In the action listener you can use the utility method to fetch a value from the table: private AbstractAction iAddStorageAbstractAction = new AbstractAction(...) { public void actionPerformed(ActionEvent e) { Standversion lStandversion = (Standversion)AbstractActionEditor.getTableModelValue(e, this, COLUMNIDX_STANDVERSION); ... The value must be fetched using TableModel.getValue in order to handle sorting. One practical hint: usually the button is displayed in one column, but you need other data to execute the action. The data in the columns often are not exactly what you need, so additional querying using an alternate key would be needed. But there is no reason why you cannot use negative column indexes (<0) to provide special data that is not shown in the table! The example above does exactly this.
,
Serialized Form| Field Summary | |
|---|---|
static java.lang.String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
static java.lang.String |
VALUE_ID_TABLE
|
| Fields inherited from class javax.swing.AbstractCellEditor |
|---|
changeEvent, listenerList |
| Constructor Summary | |
|---|---|
ActionEditorJButton(javax.swing.JTable jtable)
Initialize the editor |
|
| Method Summary | |
|---|---|
void |
construct()
initialize the editor |
java.lang.Object |
getCellEditorValue()
Return the value after the editor is done |
java.awt.Component |
getTableCellEditorComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
int row,
int column)
Return the component that is shown in the cell in the table. |
static java.lang.Object |
getTableModelValue(java.awt.event.ActionEvent e,
javax.swing.AbstractAction abstractAction,
int col)
Convenience method to do a get value from the table model |
javax.swing.table.TableCellEditor |
useAsRenderer()
|
| Methods inherited from class javax.swing.AbstractCellEditor |
|---|
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, 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 |
|---|
public static final java.lang.String SOURCECODE_VERSION
public static final java.lang.String VALUE_ID_TABLE
| Constructor Detail |
|---|
public ActionEditorJButton(javax.swing.JTable jtable)
| Method Detail |
|---|
public void construct()
public java.lang.Object getCellEditorValue()
getCellEditorValue in interface javax.swing.CellEditor
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.TableCellEditorpublic javax.swing.table.TableCellEditor useAsRenderer()
useAsRenderer in interface UseTableCellEditorAsTableCellRenderer.UseAsRenderer
public static java.lang.Object getTableModelValue(java.awt.event.ActionEvent e,
javax.swing.AbstractAction abstractAction,
int col)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||