File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Suggention on JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Suggention on JTable" Watch "Suggention on JTable" New topic
Author

Suggention on JTable

Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
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,


if (!WorkHard){
System.out.println("Fail!!!");
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41818
    
  62
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?


Ping & DNS - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Suggention on JTable