Fix dark-mode startup failures on Linux

- Apply Swing LAF synchronously on the calling thread so the main JFrame's RootPane
  has a populated UIDefaults set when constructed.  Previously the LAF install was
  scheduled via EventQueue.invokeLater, so JFrame construction raced ahead and threw
  "no ComponentUI class for: javax.swing.JPanel".
- Call LookAndFeelFactory.installJideExtension(VSNET_STYLE) with an explicit style
  instead of the no-arg auto-detection variant.  The auto-detection path probes
  com.sun.java.swing.plaf.windows.WindowsLookAndFeel via Class.forName, which is
  absent on non-Windows JDKs and threw ClassNotFoundException at startup.
- Bounce only the SwingUtilities.updateComponentTreeUI walk through the EDT so it
  redraws already-realized windows on theme toggle.
This commit is contained in:
Akumas_Coffin_
2026-05-14 19:33:39 +10:00
parent 61f7330cd2
commit 566159198e

View File

@@ -236,7 +236,10 @@ public class ThemeManager
private void applySwingLookAndFeel(boolean darkMode) private void applySwingLookAndFeel(boolean darkMode)
{ {
Runnable r = () -> { //Install the LAF synchronously on the calling thread so that any Swing components
//constructed immediately afterwards (in particular the main JFrame) find a fully
//populated UIDefaults set. UIManager.setLookAndFeel is safe to call before the EDT
//is running.
try try
{ {
if(darkMode) if(darkMode)
@@ -257,14 +260,18 @@ public class ThemeManager
try try
{ {
//JIDE components (split panes, docking) need their UI delegates re-registered //JIDE components (split panes, docking) need their UI delegates re-registered
//after every LAF change. //after every LAF change. Pass an explicit style: the no-arg version probes
LookAndFeelFactory.installJideExtension(); //com.sun.java.swing.plaf.windows.WindowsLookAndFeel which is not present on
//non-Windows JDKs, throwing ClassNotFoundException at startup.
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.VSNET_STYLE);
} }
catch(Exception e) catch(Throwable t)
{ {
mLog.warn("Unable to install JIDE LAF extension after theme change", e); mLog.warn("Unable to install JIDE LAF extension after theme change", t);
} }
//Re-rendering any already-realized Swing windows must happen on the EDT.
Runnable updateRealized = () -> {
for(Window window: Window.getWindows()) for(Window window: Window.getWindows())
{ {
SwingUtilities.updateComponentTreeUI(window); SwingUtilities.updateComponentTreeUI(window);
@@ -273,11 +280,11 @@ public class ThemeManager
if(EventQueue.isDispatchThread()) if(EventQueue.isDispatchThread())
{ {
r.run(); updateRealized.run();
} }
else else
{ {
EventQueue.invokeLater(r); EventQueue.invokeLater(updateRealized);
} }
} }