what should I do for editing all the cells of a Table? for example if in a one cell is written "abc", I want to change it to" def", how can I do that?
If you just want to edit it programmatically, then just change the value in your TableModel. A TableModel has a setValueAt(Object, int, int)
method that you can use.
If you want that the user gets a text entry field to edit the value, then you may want to read up on editors.
To make your cell user-editable, your TableModel must implement a public boolean isCellEditable(int row, int col)
method that returns true (for those cells that you want to be editable). The JTable will automatically update the TableModel trough the public void setValueAt(Object value, int row, int col)
method; you might want to use a TableModelListener
to react to those changes.
Extend TableModel class(Generally you extend AbstractTableModel) and make sure that isCellEditable(int row,int col) returns true for the cells that you want to edit.
You can have a TableModelListener for listening to changes. In order to fire events you can use the fireTableCellUpdated(int row,int col) or several other fireXXX methods whose implementation is already present in AbstractTableModel.
Also generally you may want to use your own custom Renderers and Editors in get more control. Refer to http://java.sun.com/docs/books/tutorial/uiswing/components/table.html for more details
You have to specify in your table that a given cell will be editable or not, you could do that either in JTable.isCellEditable(row, col ) or directly in the TableModel.isCellEditable(row, col) method.
That will change the UI and let you enter data:
To get the value you have to use either: JTable.setValueAt() or TableModel.setValueAt() methods.
To better understand how to use table, table models, and other features you could follow the Java tutorial: How to use Tables it is enlightening