From fb4a15f0c3fb00191404551de68975b3ea201ac3 Mon Sep 17 00:00:00 2001 From: GraxCode Date: Sun, 17 Apr 2022 15:04:39 +0200 Subject: [PATCH 1/4] Better looking tab close button. --- .../gui/resourceviewer/TabExitButton.java | 26 ++++++++------- .../gui/resourceviewer/TabbedPane.java | 32 ++++++++----------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java index 7b8889ab..75ca650b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java @@ -32,13 +32,15 @@ import javax.swing.plaf.basic.BasicButtonUI; /** * @author Konloch * @since 6/25/2021 + * Using CloseButton of darklaf instead. 4/17/2022 */ +@Deprecated public class TabExitButton extends JButton implements ActionListener { private final TabbedPane tabbedPane; private final int tabIndex; private final String tabWorkingName; - + public TabExitButton(TabbedPane tabbedPane, int tabIndex, String tabWorkingName) { this.tabbedPane = tabbedPane; @@ -62,12 +64,12 @@ public class TabExitButton extends JButton implements ActionListener // Close the proper tab by clicking the button addActionListener(this); } - + public int getTabIndex() { return tabIndex; } - + @Override public void actionPerformed(final ActionEvent e) { @@ -77,11 +79,11 @@ public class TabExitButton extends JButton implements ActionListener tabbedPane.tabs.remove(i); } } - + // we don't want to update UI for this button @Override public void updateUI() { } - + // paint the cross @Override protected void paintComponent(final Graphics g) @@ -91,33 +93,33 @@ public class TabExitButton extends JButton implements ActionListener // shift the image for pressed buttons if (getModel().isPressed()) g2.translate(1, 1); - + g2.setStroke(new BasicStroke(2)); g2.setColor(Color.BLACK); - + if (getModel().isRollover()) g2.setColor(Color.MAGENTA); - + final int delta = 6; g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1); g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1); g2.dispose(); } - + public TabbedPane getTabbedPane() { return tabbedPane; } - + public String getTabWorkingName() { return tabWorkingName; } - + public static long getSerialVersionUID() { return serialVersionUID; } - + private static final long serialVersionUID = -4492967978286454159L; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java index 582353a3..d054c8ff 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java @@ -4,7 +4,6 @@ import java.awt.Color; import java.awt.Component; import java.awt.FlowLayout; import java.awt.Rectangle; -import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -16,6 +15,8 @@ import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; + +import com.github.weisj.darklaf.components.CloseButton; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.gui.components.ButtonHoverAnimation; import the.bytecode.club.bytecodeviewer.gui.components.MaxWidthJLabel; @@ -84,7 +85,7 @@ public class TabbedPane extends JPanel // add more space between the label and the button label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); // tab button - JButton exitButton = new TabExitButton(this, tabIndex, tabWorkingName); + JButton exitButton = new CloseButton(); this.add(exitButton); // add more space to the top of the component setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); @@ -101,34 +102,24 @@ public class TabbedPane extends JPanel exitButton.setComponentPopupMenu(rightClickMenu); exitButton.addMouseListener(new MouseClickedListener(e -> { - if (e.getModifiersEx() != InputEvent.ALT_DOWN_MASK || System.currentTimeMillis() - lastMouseClick < 100) - return; - - lastMouseClick = System.currentTimeMillis(); - final int i = existingTabs.indexOfTabComponent(TabbedPane.this); - if (i != -1) - existingTabs.remove(i); + if (this.getTabIndex() != -1) + existingTabs.remove(this.getTabIndex()); })); closeTab.addActionListener(e -> { - TabExitButton tabExitButton = (TabExitButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); - final int index = tabExitButton.getTabIndex(); - - if (index != -1) - existingTabs.remove(index); + if (this.getTabIndex() != -1) + existingTabs.remove(this.getTabIndex()); }); closeAllTabs.addActionListener(e -> { - TabExitButton tabExitButton = (TabExitButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); - final int index = tabExitButton.getTabIndex(); - + while (true) { if (existingTabs.getTabCount() <= 1) return; - if (index != 0) + if (this.getTabIndex() != 0) existingTabs.remove(0); else existingTabs.remove(1); @@ -257,5 +248,8 @@ public class TabbedPane extends JPanel } private static final long serialVersionUID = -4774885688297538774L; - + + public int getTabIndex() { + return tabs.indexOfTabComponent(this); + } } From b52c194fd1380ba4ebab67b343d899df9f7c62d5 Mon Sep 17 00:00:00 2001 From: GraxCode Date: Sun, 17 Apr 2022 15:20:43 +0200 Subject: [PATCH 2/4] Make theme changes also affect components that are not in UI tree. --- .../bytecodeviewer/gui/theme/LAFTheme.java | 13 +++++++++- .../searching/impl/LDCSearch.java | 3 +++ .../impl/MemberWithAnnotationSearch.java | 3 +++ .../searching/impl/MethodCallSearch.java | 25 +++++++++++-------- .../searching/impl/RegexSearch.java | 4 +++ 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java index ac23509d..b8d24c36 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java @@ -8,7 +8,8 @@ import com.github.weisj.darklaf.theme.IntelliJTheme; import com.github.weisj.darklaf.theme.OneDarkTheme; import com.github.weisj.darklaf.theme.SolarizedDarkTheme; import com.github.weisj.darklaf.theme.SolarizedLightTheme; -import java.awt.Dialog; + +import java.awt.*; import javax.swing.JInternalFrame; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -175,4 +176,14 @@ public enum LAFTheme UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } + + /** + * Make sure that theme changes also affect components that are not in the UI tree. + */ + public static void registerThemeUpdate(Component... components) { + LafManager.registerInitTask((t, p) -> SwingUtilities.invokeLater(() -> { + for (Component component : components) + SwingUtilities.updateComponentTreeUI(component); + })); + } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java index 42e7b62e..8c8db122 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java @@ -11,6 +11,7 @@ import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.LdcInsnNode; import org.objectweb.asm.tree.MethodNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; @@ -53,6 +54,7 @@ public class LDCSearch implements SearchPanel { searchText = new JTextField(""); searchText.addKeyListener(EnterKeyEvent.SINGLETON); + LAFTheme.registerThemeUpdate(searchText); } @Override @@ -63,6 +65,7 @@ public class LDCSearch implements SearchPanel myPanel = new JPanel(new GridLayout(1, 2)); myPanel.add(new TranslatedJLabel("Search String: ", TranslatedComponents.SEARCH_STRING)); myPanel.add(searchText); + LAFTheme.registerThemeUpdate(myPanel); } return myPanel; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MemberWithAnnotationSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MemberWithAnnotationSearch.java index 2b1b19c7..56c7efab 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MemberWithAnnotationSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MemberWithAnnotationSearch.java @@ -4,6 +4,7 @@ import org.objectweb.asm.Type; import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; @@ -46,6 +47,7 @@ public class MemberWithAnnotationSearch implements SearchPanel { public MemberWithAnnotationSearch() { annotation = new JTextField(""); annotation.addKeyListener(EnterKeyEvent.SINGLETON); + LAFTheme.registerThemeUpdate(annotation); } @Override @@ -54,6 +56,7 @@ public class MemberWithAnnotationSearch implements SearchPanel { myPanel = new JPanel(new GridLayout(1, 2)); myPanel.add(new TranslatedJLabel("Annotation name: ", TranslatedComponents.ANNOTATION_NAME)); myPanel.add(annotation); + LAFTheme.registerThemeUpdate(myPanel); } return myPanel; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java index 81286178..5b0a0f67 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java @@ -1,16 +1,18 @@ package the.bytecode.club.bytecodeviewer.searching.impl; +import com.github.weisj.darklaf.LafManager; import eu.bibl.banalysis.asm.desc.OpcodeInfo; import java.awt.GridLayout; import java.util.Iterator; -import javax.swing.JPanel; -import javax.swing.JTextField; +import javax.swing.*; + import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; @@ -59,6 +61,8 @@ public class MethodCallSearch implements SearchPanel mName.addKeyListener(EnterKeyEvent.SINGLETON); mDesc = new JTextField(""); mDesc.addKeyListener(EnterKeyEvent.SINGLETON); + + LAFTheme.registerThemeUpdate(mOwner, mName, mDesc); } public JPanel getPanel() @@ -72,24 +76,25 @@ public class MethodCallSearch implements SearchPanel myPanel.add(mName); myPanel.add(new TranslatedJLabel("Desc: ", TranslatedComponents.DESC)); myPanel.add(mDesc); + LAFTheme.registerThemeUpdate(myPanel); } return myPanel; } - + @Override public void search(ResourceContainer container, String resourceWorkingName, ClassNode node, boolean exact) { final Iterator methods = node.methods.iterator(); - + String searchOwner = mOwner.getText(); if (searchOwner.isEmpty()) searchOwner = null; - + String searchName = mName.getText(); if (searchName.isEmpty()) searchName = null; - + String searchDesc = mDesc.getText(); if (searchDesc.isEmpty()) searchDesc = null; @@ -104,10 +109,10 @@ public class MethodCallSearch implements SearchPanel if (insnNode instanceof MethodInsnNode) { final MethodInsnNode min = (MethodInsnNode) insnNode; - + if (searchName == null && searchOwner == null && searchDesc == null) continue; - + if (exact) { if (searchName != null && !searchName.equals(min.name)) @@ -126,13 +131,13 @@ public class MethodCallSearch implements SearchPanel if (searchDesc != null && !min.desc.contains(searchDesc)) continue; } - + found(container, resourceWorkingName, node, method, insnNode); } } } } - + public void found(final ResourceContainer container, final String resourceWorkingName, final ClassNode node, final MethodNode method, final AbstractInsnNode insnNode) { BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult( diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java index 389ef5d7..951ec6f9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java @@ -9,6 +9,7 @@ import org.objectweb.asm.Type; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; @@ -54,6 +55,8 @@ public class RegexSearch implements SearchPanel { searchText = new JTextField(""); searchText.addKeyListener(EnterKeyEvent.SINGLETON); + + LAFTheme.registerThemeUpdate(searchText); } @Override @@ -64,6 +67,7 @@ public class RegexSearch implements SearchPanel myPanel = new JPanel(new GridLayout(1, 2)); myPanel.add(new TranslatedJLabel("Search Regex: ", TranslatedComponents.SEARCH_REGEX)); myPanel.add(searchText); + LAFTheme.registerThemeUpdate(myPanel); } return myPanel; From c803a92b01287923dca117cefb5f437ba6d53dff Mon Sep 17 00:00:00 2001 From: GraxCode Date: Sun, 17 Apr 2022 15:56:47 +0200 Subject: [PATCH 3/4] Make theme changes also affect components that are not in UI tree. #2 --- .../bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java | 3 +++ .../searching/impl/MemberWithAnnotationSearch.java | 3 +++ .../club/bytecodeviewer/searching/impl/MethodCallSearch.java | 3 +++ .../club/bytecodeviewer/searching/impl/RegexSearch.java | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java index 494d9450..4ec27f6f 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/LDCSearch.java @@ -11,6 +11,7 @@ import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.LdcInsnNode; import org.objectweb.asm.tree.MethodNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; @@ -53,6 +54,7 @@ public class LDCSearch implements SearchPanel { searchText = new JTextField(""); searchText.addKeyListener(EnterKeyEvent.SINGLETON); + LAFTheme.registerThemeUpdate(searchText); } @Override @@ -63,6 +65,7 @@ public class LDCSearch implements SearchPanel myPanel = new JPanel(new BorderLayout(16, 16)); myPanel.add(new TranslatedJLabel("Search String: ", TranslatedComponents.SEARCH_STRING), BorderLayout.WEST); myPanel.add(searchText, BorderLayout.CENTER); + LAFTheme.registerThemeUpdate(myPanel); } return myPanel; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MemberWithAnnotationSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MemberWithAnnotationSearch.java index 0887afff..ec572948 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MemberWithAnnotationSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MemberWithAnnotationSearch.java @@ -4,6 +4,7 @@ import org.objectweb.asm.Type; import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; @@ -46,6 +47,7 @@ public class MemberWithAnnotationSearch implements SearchPanel { public MemberWithAnnotationSearch() { annotation = new JTextField(""); annotation.addKeyListener(EnterKeyEvent.SINGLETON); + LAFTheme.registerThemeUpdate(annotation); } @Override @@ -54,6 +56,7 @@ public class MemberWithAnnotationSearch implements SearchPanel { myPanel = new JPanel(new BorderLayout(16, 16)); myPanel.add(new TranslatedJLabel("Annotation name: ", TranslatedComponents.ANNOTATION_NAME), BorderLayout.WEST); myPanel.add(annotation, BorderLayout.CENTER); + LAFTheme.registerThemeUpdate(myPanel); } return myPanel; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java index 3a1ec508..25e5721a 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java @@ -12,6 +12,7 @@ import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; @@ -60,6 +61,7 @@ public class MethodCallSearch implements SearchPanel mName.addKeyListener(EnterKeyEvent.SINGLETON); mDesc = new JTextField(""); mDesc.addKeyListener(EnterKeyEvent.SINGLETON); + LAFTheme.registerThemeUpdate(mOwner, mName, mDesc); } public JPanel getPanel() @@ -79,6 +81,7 @@ public class MethodCallSearch implements SearchPanel right.add(mDesc); myPanel.add(left, BorderLayout.WEST); myPanel.add(right, BorderLayout.CENTER); + LAFTheme.registerThemeUpdate(myPanel); } return myPanel; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java index e732fede..8e37fca2 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/RegexSearch.java @@ -9,6 +9,7 @@ import org.objectweb.asm.Type; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.searching.EnterKeyEvent; import the.bytecode.club.bytecodeviewer.searching.LDCSearchTreeNodeResult; @@ -54,6 +55,7 @@ public class RegexSearch implements SearchPanel { searchText = new JTextField(""); searchText.addKeyListener(EnterKeyEvent.SINGLETON); + LAFTheme.registerThemeUpdate(searchText); } @Override @@ -64,6 +66,7 @@ public class RegexSearch implements SearchPanel myPanel = new JPanel(new BorderLayout(16, 16)); myPanel.add(new TranslatedJLabel("Search Regex: ", TranslatedComponents.SEARCH_REGEX), BorderLayout.WEST); myPanel.add(searchText, BorderLayout.CENTER); + LAFTheme.registerThemeUpdate(myPanel); } return myPanel; From 7c8edb3179a9fade86ecd1f9215b2ba811f2fad0 Mon Sep 17 00:00:00 2001 From: GraxCode Date: Mon, 18 Apr 2022 11:18:19 +0200 Subject: [PATCH 4/4] Implement suggestion by @weisJ --- .../club/bytecodeviewer/gui/theme/LAFTheme.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java index b8d24c36..ec7418b5 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java @@ -1,6 +1,7 @@ package the.bytecode.club.bytecodeviewer.gui.theme; 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.HighContrastDarkTheme; 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 java.awt.*; -import javax.swing.JInternalFrame; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.*; + import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; 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. */ - public static void registerThemeUpdate(Component... components) { - LafManager.registerInitTask((t, p) -> SwingUtilities.invokeLater(() -> { - for (Component component : components) - SwingUtilities.updateComponentTreeUI(component); - })); + public static void registerThemeUpdate(JComponent... components) { + for (JComponent comp : components) { + UIUpdater.registerComponent(comp); + } } }