Sorry, brainfart.
Starting after initComponents (if done within the SwingUtilities) is bad as you are kicking it off from the Swing Event Thread, and you should, really, avoid that, if possible. Try it this way. Remove the "detectUSB" constructor and then change the main as follows:
public static void main(String args[]) {
detectUSB dusb = new detectUSB();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
dusb.initComponents().setVisible(true);
}
});
new usbThread(dusb.lbl_status).start();
}
And, in any case, change the usbThread constructor as follows:
usbThread(JLabel label) {
this.label = label;
setDaemon(true);
}
To ensure that the thread dies properly.
Edit: And, not intending to nitpick, it is standard Java programming convention to capitalise Classes so those class names
should be DetectUSB and USBThread.
Last edited by masijade; Oct 16th, 2009 at 9:55 am.
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
Offline 4,043 posts
since Feb 2006