Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You used to be able to get away with calling <code>UIManager.setLookAndFeel()</code> from outside of the Swing thread. It is probably pretty common to start out an application by setting the look and feel with that call. The Swing API docs say that the only Swing methods you may call from outside that thread are the ones labeled as <strong>thread-safe</strong> in the method's JavaDoc. <code>setLookAndFeel</code> is not labeled <code>thread-safe</code>. Since it doesn't involve displaying anything when it is called and it has always just worked, I'd bet that many people think of it as a way to set some configuration settings before actually doing anything GUI, and simply call it once and forget about it.</p> <p>Try wrapping the call to <code>UIManager.setLookAndFeel</code> the same way you do with all other Swing methods to ensure it runs in the Swing thread (sometimes referred to as the dispatch or UI thread). Also look for other Swing methods that you call outside the Swing thread in case this update has made other methods more picky in terms of their thread-safety.</p> <p><em>[added example code]</em></p> <p>@tom-clift added to his answer excellent examples showing failing code and properly working code. I am updating this answer to include a snippet of his example to show what you should replace your call to setLookAndFeel with. Do the same to with any other calls to UIManager methods, for example if you set specific properties in it.</p> <pre><code> javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload