• 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

Update Table Rows All The Time

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Here's my situation,

I have a JFrame with a tabbed pane. Inside the tabbed pane is a table containing orders.

These orders are received as an ArrayList from a rmi method which gets the orders from the database.

Now I want the table to constantly be updated, as orders are being added/edited all the time.

At the moment i'm simply implementing Runnable on my JFrame like this:



Now seems to work fine, but i do get this exception if i'm currently selecting the table and it updates.



Any of you Java 'gods' got any advice for me??

Much appreciated guys,

Regards,

David
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As for the first question, you might find that removing the "sleep" from the loop makes your program, or your database, or some other component, work too hard. But you might also find that every 10 seconds is too infrequent; that would depend on the volatility of the orders and also the requirement to see new orders "instantly".

As for the second question, go through the Concurrency in Swing tutorial.
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't rely on threads...
Better option would be make a job. Run thar job using a schedular. say for a time of 4 seconds or according to your need.

Add a finally block add schedular there.


sleep() is not a good option.
 
David Weber
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your input guys,

read up on concurrency and have now implemented ActionListener,
using swing.timer to execute the table update every 3 seconds
this is using the event-dispatch thread and so is safe to use for gui updating.

I think my problem is Solved
reply
    Bookmark Topic Watch Topic
  • New Topic