• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread problem

 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In a swing application, when ok button is clicked, i want to new a class ScanCard (implements ScannerListener and PropertyChangeListener), and I want to wait till ScanCard is finished then doAction(), if like the code showed, the doAction() is performed before or during ScanCard runing, what should I do to achieve the purpose?



Thanks.
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't look like a correct code example to me, SSCCE would be great. I can't really comprehend your question, maybe you could TellTheDetails?

If you're looking for a task that runs separate from the EDT and should notify/modify the GUI after it's finished, you may want to take a look into SwingWorker:
http://faq.javaranch.com/java/ComponentDoesntUpdatePromptly
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the confusion and thanks for the help. Yeah, that is what I want to do. When ok button is clicked, it (ScanCard) will begin scan a image and draw the image on the main window, user needs to wait during the scan process, after the drawing is finished, ScanCard finished its task and notify the the GUI, then doAction() will do further things. The SwingWorker seems the good choice, but I am using java 1.5 which do not have SwingWorker. What I should do without SwingWorker.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49849
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult for "beginning". Moving to our Swing forum.
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like mentioned already two times this week, you may want to take a look into http://foxtrot.sourceforge.net (or handle the threading yourself).
 
Rodrigo Bossini
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's possible to download SwingWorker separately from JDK 6.
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either way is cool! Thank you Peter and Rod for the information and help!! Appreciate it!

Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic