diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/ResourceViewPanel.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/ResourceViewPanel.java index 030531fe..f39d1852 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/ResourceViewPanel.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/ResourceViewPanel.java @@ -45,10 +45,13 @@ public class ResourceViewPanel public void updatePane(ClassViewer cv, byte[] b, JButton button, boolean isPanelEditable) { - updateThread = new PaneUpdaterThread(panelIndex, decompilerViewIndex) { + updateThread = new PaneUpdaterThread(panelIndex, decompilerViewIndex) + { @Override - public void doShit() { - try { + public void doShit() + { + try + { BytecodeViewer.viewer.updateBusyStatus(true); if(ResourceViewPanel.this.decompilerViewIndex > 0) @@ -70,9 +73,11 @@ public class ResourceViewPanel updateUpdaterTextArea = (SearchableRSyntaxTextArea) Configuration.rstaTheme.apply(new SearchableRSyntaxTextArea()); final Decompiler decompiler = Decompiler.decompilersByIndex.get(ResourceViewPanel.this.decompilerViewIndex); - final String decompiledSource = decompiler.getDecompiler().decompileClassNode(cv.cn, b); - //decompilerUpdate.update(decompiler.getDecompilerName(), cv.cn, b, decompiler.getDecompiler(), updateUpdaterTextArea); + //perform decompiling inside of this thread + final String decompiledSource = decompiler.getDecompiler().decompileClassNode(cv.cn, b); + + //set the swing components on the swing thread SwingUtilities.invokeLater(() -> { panel.add(updateUpdaterTextArea.getScrollPane()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabButton.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java similarity index 93% rename from src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabButton.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java index f9aa0edb..54c07a46 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabButton.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java @@ -10,13 +10,13 @@ import java.awt.event.ActionListener; * @author Konloch * @since 6/25/2021 */ -public class TabButton extends JButton implements ActionListener +public class TabExitButton extends JButton implements ActionListener { private final TabbedPane tabbedPane; private final int tabIndex; private final String tabWorkingName; - public TabButton(TabbedPane tabbedPane, int tabIndex, String tabWorkingName) + public TabExitButton(TabbedPane tabbedPane, int tabIndex, String tabWorkingName) { this.tabbedPane = tabbedPane; this.tabIndex = tabIndex; 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 8cdd9e55..d54871a8 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 @@ -73,8 +73,8 @@ 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 button = new TabButton(this, tabIndex, tabWorkingName); - this.add(button); + JButton exitButton = new TabExitButton(this, tabIndex, tabWorkingName); + this.add(exitButton); // add more space to the top of the component setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); @@ -87,8 +87,8 @@ public class TabbedPane extends JPanel rightClickMenu.add(closeTab); //setComponentPopupMenu(rightClickMenu); - button.setComponentPopupMenu(rightClickMenu); - button.addMouseListener(new MouseClickedListener(e -> + exitButton.setComponentPopupMenu(rightClickMenu); + exitButton.addMouseListener(new MouseClickedListener(e -> { if (e.getModifiers() != InputEvent.ALT_MASK || System.currentTimeMillis() - lastMouseClick < 100) return; @@ -101,16 +101,16 @@ public class TabbedPane extends JPanel closeTab.addActionListener(e -> { - TabButton tabButton = (TabButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); - final int index = tabButton.getTabIndex(); + TabExitButton tabExitButton = (TabExitButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); + final int index = tabExitButton.getTabIndex(); if (index != -1) existingTabs.remove(index); }); closeAllTabs.addActionListener(e -> { - TabButton tabButton = (TabButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); - final int index = tabButton.getTabIndex(); + TabExitButton tabExitButton = (TabExitButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); + final int index = tabExitButton.getTabIndex(); while (true) { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneMainComponent.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneMainComponent.java index d183bc38..b19b2525 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneMainComponent.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneMainComponent.java @@ -67,16 +67,16 @@ public class WorkPaneMainComponent extends VisibleComponent JMenuItem closeTab = new JMenuItem("Close Tab"); closeTab.addActionListener(e -> { - TabButton tabButton = (TabButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); - final int index = tabButton.getTabIndex(); + TabExitButton tabExitButton = (TabExitButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); + final int index = tabExitButton.getTabIndex(); if (index != -1) tabs.remove(index); }); closeAllTabs.addActionListener(e -> { - TabButton tabButton = (TabButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); - final int index = tabButton.getTabIndex(); + TabExitButton tabExitButton = (TabExitButton) ((JPopupMenu)((JMenuItem) e.getSource()).getParent()).getInvoker(); + final int index = tabExitButton.getTabIndex(); while (true) {