Hi guys.
I'm new to Swing and currently I'm having some problems. I want to observe a certain folder, and whenever a new image file is copied to it or created in the folder, i want to display it in my Swing Application. So far I've made a simple app with a panel and an ImageIcon which I've read from the file system. This is working fine.
Now I want to expand my application. I thought I could make a swing worker thread (which is running all the time to observe the folder for new files).
So my plan was to get the file list of the directory, then sleep the worker thread for a while and then read the files again. If the length of the file list is longer than before, then i can return the last fileitem.
However I'm running into some trouble. It looks like the Worker Thread has no sleep function. And also my plan to observe the folder results in either an endless loop or my GUI is frozen until the Thread is finished. Because the plan was to never let the Thread finish, my GUI will be frozen forever.
I'd appreciate if anyone has some better ideads to observe a folder or could help me with these Worker Threads.
Greetings Florian