mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Re-apply FlatLaf defaults after JIDE install + strengthen FX borders
Symptom: With dark mode enabled, the Swing main window's spectrum chrome and menu bar were dark (FlatLaf) but tables, tabbed panes and the inner content area were light/Metal coloured. Root cause: LookAndFeelFactory.installJideExtension installs JIDE's Metal-flavored UI defaults (VsnetMetalUtils etc.) into the live UIDefaults table, overwriting FlatLaf's standard component colors and fonts for keys like Table.background, TabbedPane.foreground, Panel.background. Fix: After the JIDE install, walk a fresh FlatLaf UIDefaults table and put every key back into the active defaults, skipping anything Jide-prefixed. JIDE's UI delegate registrations live under Jide* keys that FlatLaf does not define, so they survive untouched while the standard Swing color and font keys are restored to their dark equivalents. Also strengthen the JavaFX dark stylesheet: explicit borders on text fields, tables, titled panes, split-pane dividers and separators so components have more defining outlines in dark mode.
This commit is contained in:
@@ -34,7 +34,9 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Scene;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
import org.slf4j.Logger;
|
||||
@@ -241,16 +243,11 @@ public class ThemeManager
|
||||
//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.
|
||||
LookAndFeel newLaf;
|
||||
try
|
||||
{
|
||||
if(darkMode)
|
||||
{
|
||||
UIManager.setLookAndFeel(new FlatDarkLaf());
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.setLookAndFeel(new FlatLightLaf());
|
||||
}
|
||||
newLaf = darkMode ? new FlatDarkLaf() : new FlatLightLaf();
|
||||
UIManager.setLookAndFeel(newLaf);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -261,11 +258,9 @@ public class ThemeManager
|
||||
try
|
||||
{
|
||||
//JIDE 3.6.18 has compile-time `instanceof WindowsLookAndFeel` checks throughout
|
||||
//LookAndFeelFactory. On Linux/macOS JDKs that class is not present at all, so any
|
||||
//call path that reaches those checks fails with NoClassDefFoundError. The 3-arg
|
||||
//overload lets us hand JIDE an explicit Metal LAF instance for *type detection*
|
||||
//while leaving the real (FlatLaf) defaults table in place; JIDE's Metal branch
|
||||
//matches first and the Windows branch is never reached.
|
||||
//LookAndFeelFactory. The 3-arg overload lets us hand JIDE an explicit Metal LAF
|
||||
//instance for type detection while leaving the real (FlatLaf) defaults table in
|
||||
//place; JIDE's Metal branch matches first.
|
||||
LookAndFeelFactory.installJideExtension(UIManager.getLookAndFeelDefaults(),
|
||||
new MetalLookAndFeel(), LookAndFeelFactory.VSNET_STYLE);
|
||||
}
|
||||
@@ -274,6 +269,41 @@ public class ThemeManager
|
||||
mLog.warn("Unable to install JIDE LAF extension after theme change", t);
|
||||
}
|
||||
|
||||
//JIDE's Metal-flavored extension overwrites FlatLaf's color/font/border defaults for
|
||||
//standard Swing component keys (Table.background, TabbedPane.foreground, etc.) which
|
||||
//leaves the inner content of the app looking like a Metal LAF island in a FlatLaf
|
||||
//chrome. Re-apply FlatLaf's standard defaults on top of JIDE's install - JIDE's UI
|
||||
//delegate registrations live under Jide-prefixed keys that FlatLaf does not define,
|
||||
//so they survive untouched.
|
||||
try
|
||||
{
|
||||
UIDefaults flatFresh = (darkMode ? new FlatDarkLaf() : new FlatLightLaf()).getDefaults();
|
||||
UIDefaults active = UIManager.getLookAndFeelDefaults();
|
||||
for(java.util.Map.Entry<Object, Object> entry: flatFresh.entrySet())
|
||||
{
|
||||
Object key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
String keyName = String.valueOf(key);
|
||||
|
||||
//Do not overwrite JIDE-specific keys, even though FlatLaf would not normally
|
||||
//define them - belt-and-braces in case a future FlatLaf version adds keys
|
||||
//whose names happen to start with "Jide".
|
||||
if(keyName.startsWith("Jide") || keyName.contains(".Jide"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(value != null)
|
||||
{
|
||||
active.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Throwable t)
|
||||
{
|
||||
mLog.warn("Unable to re-apply FlatLaf defaults after JIDE install", t);
|
||||
}
|
||||
|
||||
//Re-rendering any already-realized Swing windows must happen on the EDT.
|
||||
Runnable updateRealized = () -> {
|
||||
for(Window window: Window.getWindows())
|
||||
|
||||
Reference in New Issue
Block a user