@@ -255,7 +255,36 @@ protected void createUI() {
255255 // catch and throw a RuntimeException in response, thereby
256256 // avoiding any subsequent output shenanigans past this point.
257257 if (!Boolean .getBoolean (ConsolePane .NO_CONSOLE_PROPERTY )) {
258- consolePane = new SwingConsolePane (getContext ());
258+ final String [] lafsToTry = {
259+ null , // the default look and feel, as set by initLookAndFeel()
260+ // e.g. Linux=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
261+ javax .swing .UIManager .getSystemLookAndFeelClassName (),
262+ "Nimbus" , // because it's nicer than Metal
263+ // javax.swing.plaf.metal.MetalLookAndFeel
264+ javax .swing .UIManager .getCrossPlatformLookAndFeelClassName ()
265+ };
266+ // NB: Ideally we would try these multiple LAFs regardless of if the
267+ // console is enabled or not. However, when a LAF explodes due to missing
268+ // ComponentUI, Java does printStackTrace() internally and does *not*
269+ // throw an exception! So we can't try/catch any `new SwingComponent()`;
270+ // we specifically need to do it with the ConsolePane, which has special
271+ // logic for detecting infinite console output loops that throws
272+ // RuntimeException when this sort of nonsense happens.
273+ for (final String laf : lafsToTry ) {
274+ if (laf != null && lafService != null ) lafService .setLookAndFeel (laf );
275+ try {
276+ consolePane = new SwingConsolePane (getContext ());
277+ break ;
278+ }
279+ catch (final RuntimeException exc ) {
280+ log .error ("Failed to configure UI with " + //
281+ (laf == null ? "default" : laf ) + " Look+Feel" , exc );
282+ if (lafService == null ) break ;
283+ }
284+ }
285+ if (consolePane == null ) {
286+ throw new IllegalStateException ("Failed to configure UI Look+Feel!" );
287+ }
259288 }
260289
261290 final JMenuBar menuBar = createMenus ();
0 commit comments