Better Looking Busy Wait Icons

This commit is contained in:
Konloch 2021-07-04 03:23:14 -07:00
parent e3a1d9b6f6
commit ba6e59e2c3
4 changed files with 63 additions and 10 deletions

View file

@ -104,6 +104,8 @@ import static the.bytecode.club.bytecodeviewer.util.MiscUtils.guessLanguage;
* + Add decompile all as zip for CLI * + Add decompile all as zip for CLI
* *
* TODO IDEAS: * 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 * + 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 * ^ 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 * + Look into removing the loaded classes from inside the FileContainer & then generate the ClassNodes on demand

View file

@ -1,7 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui; package the.bytecode.club.bytecodeviewer.gui;
import java.awt.Dimension; import java.awt.*;
import java.awt.KeyboardFocusManager;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -748,14 +747,8 @@ public class MainViewerGUI extends JFrame
{ {
if (busy) if (busy)
{ {
JMenuItem waitIcon = new JMenuItem(""); JMenuItem waitIcon = new WaitBusyIcon();
waitIcon.setMaximumSize(new Dimension(20, 50));
waitIcon.setEnabled(false);
try {
waitIcon.setIcon(Resources.busyIcon);
} catch (NullPointerException e) {
waitIcon.setIcon(Resources.busyB64Icon);
}
rootMenu.add(waitIcon); rootMenu.add(waitIcon);
waitIcons.add(waitIcon); waitIcons.add(waitIcon);
} }

View file

@ -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);
}
}

View file

@ -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;
}
}