FileTree (JTree) and GUI delays
I have created a JTree with a custom TreeModel, FileTreeModel. It works as expected, and I've tried to make the code as efficient as possible.
When I expand a folder that contains many files, the GUI pauses - I know I shouldn't have code that takes awhile to execute do so on the Event Dispatching Thread, but how do I get around it?
I've just started to wrap my head around the new SwingWorker class version included in JDK 1.6, but I'm having difficulty in getting it to work for my purposes.
Expanding a directory causes the model to read the subfiles, and sort them alphabetically, directories first, then files.
Should I, and how could I move this method into a seperate thread? Or should I, and how do I, reliably change to the busy cursor for the few seconds of processing?
If I use a dedicated thread, I obviously need the repainting of the JTree to wait for the model to be updated, which is why I was lookiong at the new SwingWorker.
I'm searching forums and JavaRanch, but as the new SwingWorker is new to 1.6, I'm having difficulty figuring this out. Thanks in advance.