• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Load JTable Data

 
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
 
Greenhorn
Posts: 8
Eclipse IDE Oracle Java
  • 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
 
Sheriff
Posts: 21760
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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.
 
Rancher
Posts: 3053
22
  • 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!