• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem Updating Content Of JTable

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey thanks Rob..Sorry for the last reply, I actually wrote that before trying. SetValueAt is working fine if i give some constant value.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic