File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Problem Updating Content Of JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem Updating Content Of JTable" Watch "Problem Updating Content Of JTable" New topic
Author

Problem Updating Content Of JTable

Navjot Singh
Greenhorn

Joined: Aug 18, 2011
Posts: 5
Hi,
I am new to JAVA and NetBeans. My problem is basically to dynamically update the contents of Jtable when an event (such as a button click occurs). I am using the following function to do the same in event handling function:

jTable1.setValueAt(celval, jTable1.getEditingRow(), jTable1.getEditingColumn());


I have verified the values returned by celval( A String) , getEditingRow (gives the row number of the selected cell.) , getEditingColumn(gives the column number of the selected cell).

But the problem is that setValueAt neither updates the cell value( I tried verifying by using getValueAt function) nor does it update the values being displayed in the GUI. Can anyone tell me how to correctly use this function.

The JTable is used here is has DefaultTableModel as its Model. ( Honestly, I dont know much about that, I just used NetBeans drag and drop. )

Am pasting the code as generated by NetBeans for this JTable.




Any help would be greatly appreciated.
Thanks!
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
It doesn't make sense to me that the editing row/column would have valid values when you click a button because cell editing should be stopped. I would try the getSelectedRow/Column methods.

Post your SSCCE that demonstrates the problem.
Navjot Singh
Greenhorn

Joined: Aug 18, 2011
Posts: 5
Lets Simplifiy the problem to

jTable1.setValueAt("Some String",1,1)

every time a button is clicked.

Even this doesnt work correctly. ( My table has more than two rows and columns ) .
Navjot Singh
Greenhorn

Joined: Aug 18, 2011
Posts: 5
Hey thanks Rob..Sorry for the last reply, I actually wrote that before trying. SetValueAt is working fine if i give some constant value.
 
wood burning stoves
 
subject: Problem Updating Content Of JTable
 
Similar Threads
JTable Problem
JTable cell focus
Problem with JTable
Jtable uneditable cells in a specific table column (regardless of row)
JTable Custon Renderes