File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes thread problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "thread problem" Watch "thread problem" New topic
Author

thread problem

david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
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

Joined: Nov 18, 2006
Posts: 174
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


Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
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

Joined: Oct 13, 2005
Posts: 38726
    
  23
Too difficult for "beginning". Moving to our Swing forum.
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
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

Joined: Jul 03, 2009
Posts: 113
It's possible to download SwingWorker separately from JDK 6.


I see wind mills
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
Either way is cool! Thank you Peter and Rod for the information and help!! Appreciate it!

Regards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: thread problem