• 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

Load JTable Data

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 8
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anuj Joshi,
can you put a snap shoot to can help you ?
Thanks

Eng.Ahmed
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a DefaultTableModel. You can use the addColumn(...) method to add a new column of information as required.
 
reply
    Bookmark Topic Watch Topic
  • New Topic