I\'m having an issue with Threads using netbeans Swing GUI. This is my first time really trying to develop a GUI for a backup program using Java\'s File System Notifier. I h
In support of davidbuzatto:
No, I think you miss under stood what InvokeLater does. InvokeLater ensures that the runnable is executed ON the ETD. So basically, from what I can read, you've gone an put your long running, Event Blocking code right back in the ETD. Only use InvokeLater when you want to update the UI, use Threads or SwingWorker when you want to actually do processing
void processEvents() throws IOException, InterruptedException
{
System.out.println("Entered processEvents");
// PLEASE ETD, PUT THIS AT THE END OF THE QUEUE AND EXECUTE
// SO I RUN WITHIN YOUR CONTEXT
SwingUtilities.invokeLater(new Runnable() {
public void run()
{
// NOW RUNNING BACK ON THE ETD
System.out.println("Entered run");
list.add("test2");
list.repaint();
// NOW BLOCK THE ETD, SO NO MORE REPAINTS OR UPDATES WILL EVER
// OCCUR
while(true)
{
WatchKey key;
try
{
key = ws.take();
}
catch (InterruptedException x)
{
return;
}
Sorry for the caps, but I wanted the comments to standout.