diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index 695d5f6e..4152a8ce 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -104,6 +104,8 @@ import static the.bytecode.club.bytecodeviewer.util.MiscUtils.guessLanguage; * + Add decompile all as zip for CLI * * TODO IDEAS: + * + Add the setting to force all non-classes to be opened with the Hex Viewer + * ^ Optionally a right-click menu open-as would work inside of the resource list * + Allow class files to be opened without needing the .class extension * ^ Easiest way to do this is to read the file header CAFEBABE on resource view * + Look into removing the loaded classes from inside the FileContainer & then generate the ClassNodes on demand diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java index 4d960fc0..b1cfc4bd 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -1,7 +1,6 @@ package the.bytecode.club.bytecodeviewer.gui; -import java.awt.Dimension; -import java.awt.KeyboardFocusManager; +import java.awt.*; import java.io.File; import java.util.ArrayList; import java.util.HashMap; @@ -748,14 +747,8 @@ public class MainViewerGUI extends JFrame { if (busy) { - JMenuItem waitIcon = new JMenuItem(""); - waitIcon.setMaximumSize(new Dimension(20, 50)); - waitIcon.setEnabled(false); - try { - waitIcon.setIcon(Resources.busyIcon); - } catch (NullPointerException e) { - waitIcon.setIcon(Resources.busyB64Icon); - } + JMenuItem waitIcon = new WaitBusyIcon(); + rootMenu.add(waitIcon); waitIcons.add(waitIcon); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JMenuItemIcon.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JMenuItemIcon.java new file mode 100644 index 00000000..66616004 --- /dev/null +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JMenuItemIcon.java @@ -0,0 +1,32 @@ +package the.bytecode.club.bytecodeviewer.gui.components; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Konloch + * @since 7/4/2021 + */ +public class JMenuItemIcon extends JMenuItem +{ + public JMenuItemIcon(Icon icon) + { + super(""); + + setIcon(icon); + setAlignmentY(0.65f); + Dimension size = new Dimension((int) (icon.getIconWidth()*1.4), icon.getIconHeight()); + setSize(size); + setPreferredSize(size); + setMinimumSize(size); + setMaximumSize(size); + } + + @Override + public void paint(Graphics g) + { + g.setColor(UIManager.getColor("Panel.background")); + g.fillRect(0, 0, getWidth(), getHeight()); + super.paint(g); + } +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/WaitBusyIcon.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/WaitBusyIcon.java new file mode 100644 index 00000000..d748f25a --- /dev/null +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/WaitBusyIcon.java @@ -0,0 +1,26 @@ +package the.bytecode.club.bytecodeviewer.gui.components; + +import the.bytecode.club.bytecodeviewer.Resources; + +import javax.swing.*; + +/** + * @author Konloch + * @since 7/4/2021 + */ +public class WaitBusyIcon extends JMenuItemIcon +{ + public WaitBusyIcon() + { + super(loadIcon()); + setAlignmentY(0.65f); + } + + public static Icon loadIcon() + { + if(Resources.busyIcon != null) + return Resources.busyIcon; + + return Resources.busyB64Icon; + } +}