C:\Documents and Settings\Administrator\Desktop>java -version
java version "1.6.0_10-beta"
Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b25)
Java HotSpot(TM) Client VM (build 11.0-b12, mixed mode, sharing)
The exception happens at start-up time when creating the Swing objects in different threads.
As it's thread related it is not always reproducable but I have it at more than 9/10. Start the application several times then to see it.
I use Win XP/sp2 with build 1.6.0_10-beta-b25
Start test case over and over again, it may take 10+ times before you see the exception, sooner on a multi-cpu system.
---------------------test case--------------------------------------------
import java.awt.*;
import javax.swing.*;
// javac TestNimbusThreading.java
// java -Dswing.defaultlaf=com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel TestNimbusThreading
public class TestNimbusThreading {
public TestNimbusThreading() {
try {
final JFrame mainFrame = new JFrame();
final JPanel jpGrid = new JPanel(new GridLayout(5,5));
final SwingObjectCreation[] tableCreation = new SwingObjectCreation[25];
for (int i=0; i<tableCreation.length; i++) {
tableCreation[i] = new SwingObjectCreation();
tableCreation[i].start();
}
for (int i=0; i<tableCreation.length; i++) {
tableCreation[i].join();
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
for (int i=0; i<tableCreation.length; i++) {
jpGrid.add(new JScrollPane(tableCreation[i].getTable()));
}
mainFrame.getContentPane().add(jpGrid);
mainFrame.pack();
mainFrame.setVisible(true);
mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
new TestNimbusThreading();
}
public static class SwingObjectCreation extends Thread {
private JTable table;
public void run() {
table = new JTable(3,2);
}
public JTable getTable() {
return table;
}
}
}
---------------------------end test case -------------------------------