I'm searching for an editor like in this example; I mean the "Pick a Color"-Frame, but for the whole row. Is it my issue to fully implement this, or can I expand some exsiting editors?
-
You can specify one editor for each data type in your table, using the JTable `setDefaultEditor` method. – Gilbert Le Blanc Jan 24 '13 at 14:49
-
1What do you mean with "for the hole row"? – Hendrik Ebbers Jan 24 '13 at 15:14
-
something like an child window, with some textfileds/checkboxes, instead of an editor for one cell. – Merlin Bögershausen Jan 25 '13 at 08:15
2 Answers
The default renderers and editors for common column data types are shown here. An editor is chosen for any cell in any row for which isCellEditable() returns true. You can also specify a custom renderer and editor, such as the color chooser you cited. Two recent examples are seen here, but the details depend on your use-case.
Addendum: something like an child window
You can pass a reference to the table's TableModel and the desired row number to your RowEditor. You'll have full access to the table model's methods, including getValueAt(), setValueAt() and getColumnClass() methods.
-
you mean i have to extend the default rendere to implement my own "RowEditor" – Merlin Bögershausen Jan 25 '13 at 08:17
-
Not necessarily. "In [`SimpleTableDemo`](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#eg), all cells are editable." I've elaborated above on your comment about a child window. – trashgod Jan 25 '13 at 09:29
-
i know, but i would like an popup with textfileds for entering new values for all cell in this specific row. – Merlin Bögershausen Jan 25 '13 at 09:36
-
You might try a `JOptionPane`, as shown [here](http://stackoverflow.com/a/3002830/230513). – trashgod Jan 25 '13 at 09:48
-
do i need the hole `TableModel` or is the `TabelColumnModel` enough? – Merlin Bögershausen Jan 25 '13 at 09:53
-
If you want the entire row, with columns A, B, C edited in a new child window as
A ____
B ____
C ____
Then maybe you could make the row of some bean class Record, and use a java.beans.PropertyEditor to start with.
- 107,315
- 7
- 83
- 138