Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Suggention on JTable  RSS feed

 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

i am now doing a project which link to my data base. Now i am using JTable to display my result. But i was thinking to let the user to edit the data on the table instade of using a form to input the data then udate the data.

So i would like to ask if there is a way of editing my database from my JTable something like real-time editing .

all suggesztion are welcome thanks very much.

regards,
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cells in a JTable can be editable - check out the TableCellEditor interface. Is your problem the editing of the values, or the storing of altered values in the DB?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to update the database when the user stops editing a field, you should create a custom TableCellEditor. The best way is to subclass DefaultCellEditor, and override stopCellEditing as follows:
But keep in mind that this will update your table every time a value is edited and the change is "committed" in the table. If you need to edit a lot of columns in one row, you will have an update for every column. One bulk update of the entire row would be better.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!