Results 1 to 3 of 3
- 12-09-2009, 02:32 AM #1
Member
- Join Date
- Sep 2009
- Posts
- 41
- Rep Power
- 0
wait() and notify() trouble with UI
I have a program to copy images to another folder, and Im implementing a method to ask before overwriting an image of the same name. So in the loop of copying files, it checks if it already exists. If it does, then It displays a JDialog with the question. Since it checks in a loop, it has to use wait() to wait for the person to click the button. But whenever it hits the wait(), it does not update the images or the buttons on the JDialog until notified (which cant be done because you cant click on the button) even though im just using SetVisible(true) for the displaying of the dialog.
How can i fix this?
I know i might have to split it into two threads, but i dont know how i would do that with a jdialog.
So in a nutshell, I need a way to run my loop, check for a problem, pause the loop, display a dialog to fix the problem, continue loop.
thanks!
ps: i have looked up quite a bit about wait() and synchronization, but i cant seem to find what im looking for.
-
This is event-driven programming so you shouldn't have to call wait() and if you did call it on the EDT, you will freeze the EDT and your whole app. So just don't do it.
Perhaps you want to check file existence first in a loop on your EDT and get the user input. Then after getting all the information you need, create a background thread (such as by using a SwingWorker object) and do your image file copying.
- 12-09-2009, 02:51 AM #3
Member
- Join Date
- Sep 2009
- Posts
- 41
- Rep Power
- 0
Similar Threads
-
wait() and notify() problems
By greyradio in forum Threads and SynchronizationReplies: 1Last Post: 08-03-2009, 03:36 AM -
Make a program notify
By McChill in forum New To JavaReplies: 7Last Post: 06-03-2009, 09:17 PM -
What is the execution path of wait() and notify() ?
By AegisCruiser in forum Threads and SynchronizationReplies: 1Last Post: 04-23-2008, 06:16 PM -
How to use sleep() to wait for a while
By Java Tip in forum java.langReplies: 0Last Post: 04-09-2008, 06:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks