• Post Reply Bookmark Topic Watch Topic
  • New Topic

Building UI and listModel separately

 
Peter Simard
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a utility which prsents the user with a list of items to delete from a database.
I'd like to do the DB query via a separate thread while the GUI is being built, then populate the JList with the results of the query.
Since run() has a void return type, can someone suggest a way to work around this?
As the target table in the DB grows, so does the time to build this UI, so I'd like to reduce that time by separating the building of the UI from the query to the DB.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create classes for each Thread (or Runnable) which have additional fields and methods for transferring the results of their respective run() methods:

Alternately this can be done more concisely with anonymous classes:

I recommend the latter only if the two run() methods are reasonably short (in terms of visual space, not necessarily execution time). Otherwise you'll have a lot of unreadable code on your hands...
[ December 08, 2002: Message edited by: Jim Yingst ]
 
Peter Simard
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your input...I'll get back with my results.
Pete
 
Peter Simard
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many many thanks, that works as i hoped...speeds things up noticeably.
And...adds to my understanding of Threads much more.
Happy Holidays,
Pete
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!