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
1. Swing is Not Thread safe, but some methods like repaint(), setText() are Tread Safe.
2. The main() method in Swing is Not Long Lived. It schedules the construction of GUI in the Event Dispactcher Thread and then quits. Now its the responsibility of the EDT to handle the GUI.
3. You must keep your Non-UI work on your Non-UI thread, out off the GUI thread, ie EDT.
4. Your main() method should only do the work of making the JFrame visible, using EventQueue.invokeLater.
Eg:
public static void main(String[] args){
EventQueue.invokeLater(new Runnable(){
public void run(){
myFrame.setVisible(true);
}
}
}
5 SwingWorker is provided by Java to Synchronize the Work Output of the Non-UI thread on the GUI thread.