You have an intermittent exception being thrown from a Swing GUI which highly suggests that this is a concurrency/threading issue. Are you starting the GUI on the Swing event dispatch thread? If not, please be sure to do this, especially with some Look & Feels such as Nimbus. In other words — create your GUI within a Runnable and queue that onto the Swing event queue using SwingUtilities.invokeLater(...)
.
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
// create your Swing GUI and set the L&F here
});
}
If this is not the problem, then still look for other Swing threading issues, possibly using one of the approaches cited here.
Please see this bug report on the same issue. It was closed as a “non-issue” because:
This is most definitely a multithreading issue.
Again, I can now say with confidence that yours is a threading issue, that the way to solve it is to go through your code and find out where your code is violating Swing’s threading rules, because most certainly it is. If you need our help, then you must show us your pertinent code, that is, code that might be violating Swing threading rules. If you won’t show code, we can’t give specific help.
2
solved how to avoid this ClassCastException? [closed]