Implement suggestion by @weisJ

This commit is contained in:
GraxCode 2022-04-18 11:18:19 +02:00
parent c803a92b01
commit 7c8edb3179

View file

@ -1,6 +1,7 @@
package the.bytecode.club.bytecodeviewer.gui.theme; package the.bytecode.club.bytecodeviewer.gui.theme;
import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.listener.UIUpdater;
import com.github.weisj.darklaf.theme.DarculaTheme; import com.github.weisj.darklaf.theme.DarculaTheme;
import com.github.weisj.darklaf.theme.HighContrastDarkTheme; import com.github.weisj.darklaf.theme.HighContrastDarkTheme;
import com.github.weisj.darklaf.theme.HighContrastLightTheme; import com.github.weisj.darklaf.theme.HighContrastLightTheme;
@ -10,10 +11,8 @@ import com.github.weisj.darklaf.theme.SolarizedDarkTheme;
import com.github.weisj.darklaf.theme.SolarizedLightTheme; import com.github.weisj.darklaf.theme.SolarizedLightTheme;
import java.awt.*; import java.awt.*;
import javax.swing.JInternalFrame; import javax.swing.*;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.SettingsDialog; import the.bytecode.club.bytecodeviewer.gui.components.SettingsDialog;
@ -180,10 +179,9 @@ public enum LAFTheme
/** /**
* Make sure that theme changes also affect components that are not in the UI tree. * Make sure that theme changes also affect components that are not in the UI tree.
*/ */
public static void registerThemeUpdate(Component... components) { public static void registerThemeUpdate(JComponent... components) {
LafManager.registerInitTask((t, p) -> SwingUtilities.invokeLater(() -> { for (JComponent comp : components) {
for (Component component : components) UIUpdater.registerComponent(comp);
SwingUtilities.updateComponentTreeUI(component); }
}));
} }
} }