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

Load JTable Data  RSS feed

 
Anuj Joshi
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to add data on JTable & I want to load data firstly on first column & then I want add second column data one by one after some time of interval...

i.e. when I started my application I can see left column data filled but not in the 2nd column. & after some time 2nd column data should start filling one by one.

Please help me.

Your guidance really helped me a lot.

Thanks
 
Ahmed Elemam
Greenhorn
Posts: 8
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anuj Joshi,
can you put a snap shoot to can help you ?
Thanks

Eng.Ahmed
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on the processing power needed to fill the data, you could use a javax.swing.Timer or a javax.swing.SwingWorker. Use the JTable's setValueAt method (or its model's setValueAt method) to update the values.

If the values just need to be set a Timer should be enough. If you need a heavy calculation you don't want to use Timer since the code will then be run on the Event Dispatcher Thread (EDT), during which time the user interface is not responsive. A SwingWorker will then be better, using its publish / process methods. See this thread for more information. But how it should work, basically, is this:
- doInBackground does the hard work.
- now and then it uses publish to indicate a new value is ready. You probably need a little container class that stores the row, column and value.
- process then only uses those values to set them in the table / model.
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a DefaultTableModel. You can use the addColumn(...) method to add a new column of information as required.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!