How can I change data in JTable cells?

I can set the data in the JTable's constructor and then the user can change that data when the program is manually started (keyboard input).

But what method should I use if I want to change data in a certain column? To change the column header, I use the TableColumn setHeaderValue method. What should I use to set a value in a JTable cell?

+1


source to share


2 answers


If you want to allow users to edit data, you need to set TableCellEditor on the cells you want to edit. You probably also want to start using the TableModel instead of hardcoding the data into the JTable itself.



See http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

+1


source


When creating a JTable, you first need to specify that the values โ€‹โ€‹of a particular column are editable. Obviously, you can also provide line editing functionality. but all of these things you must define when creating the table itself. Please answer if you need help.



0


source







All Articles