Skip to content

Commit

Permalink
Add MainGUI launch buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Mar 21, 2024
1 parent e71f78d commit 4a9098d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
52 changes: 51 additions & 1 deletion convex-gui/src/main/java/convex/gui/MainGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
import java.awt.EventQueue;
import java.awt.event.WindowEvent;

import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.JComponent;

import convex.core.crypto.AKeyPair;
import convex.gui.components.ActionPanel;
import convex.gui.manager.mainpanels.HomePanel;
import convex.gui.utils.Toolkit;
import net.miginfocom.swing.MigLayout;
Expand All @@ -19,7 +27,49 @@ public MainGUI() {
MigLayout layout=new MigLayout("center");
setLayout(layout);

add(new HomePanel());
add(new HomePanel(),"dock center");

ActionPanel actionPanel=new ActionPanel();
actionPanel.setLayout(new MigLayout("center,align center,fillx"));

JComponent testNet=createLaunchButton("Launch TestNet",Toolkit.TESTNET_ICON,this::launchTestNet);
actionPanel.add(testNet);

JComponent terminal=createLaunchButton("Convex Terminal",Toolkit.TERMINAL_ICON,this::launchTestNet);
actionPanel.add(terminal);

JComponent hacker=createLaunchButton("Hacker Tools",Toolkit.HACKER_ICON,this::launchTestNet);
actionPanel.add(hacker);

JComponent discord=createLaunchButton("Community Discord",Toolkit.ECOSYSTEM_ICON,this::launchTestNet);
actionPanel.add(discord);

JComponent www=createLaunchButton("https://convex.world",Toolkit.WWW_ICON,this::launchTestNet);
actionPanel.add(www);



add(actionPanel,"dock south");
}

public void launchTestNet() {
PeerGUI.launchPeerGUI(3, AKeyPair.generate());
}

public JPanel createLaunchButton(String label, ImageIcon icon, Runnable cmd) {
JButton butt=new JButton(icon);
butt.addActionListener(e->{
EventQueue.invokeLater(cmd);
});

JLabel lab = new JLabel(label);
lab.setHorizontalAlignment(SwingConstants.CENTER);

JPanel panel=new JPanel();
panel.setLayout(new MigLayout());
panel.add(butt,"dock center");
panel.add(lab,"dock south");
return panel;
}

@Override
Expand Down
5 changes: 5 additions & 0 deletions convex-gui/src/main/java/convex/gui/utils/Toolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ public class Toolkit {
public static final ImageIcon COG = scaledIcon(36, "/images/cog.png");
public static final ImageIcon REPL_ICON = scaledIcon(36, "/images/terminal-icon.png");

public static final ImageIcon TESTNET_ICON = scaledIcon(128, "/images/testnet.png");
public static final ImageIcon WWW_ICON = scaledIcon(128, "/images/www.png");
public static final ImageIcon HACKER_ICON = scaledIcon(128, "/images/hacker.png");
public static final ImageIcon TERMINAL_ICON = scaledIcon(128, "/images/terminal.png");
public static final ImageIcon ECOSYSTEM_ICON = scaledIcon(128, "/images/ecosystem.png");

public static ImageIcon scaledIcon(int size, String resourcePath) {
java.net.URL imgURL = Toolkit.class.getResource(resourcePath);
Expand Down
Binary file not shown.
Binary file added convex-gui/src/main/resources/images/terminal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4a9098d

Please sign in to comment.