Skip to content

Commit 2e9c7c6

Browse files
committed
feat: add menu bar with file and help options to CosmicJarsFrame
- Added a menu bar with 'File' and 'Help' menus. - 'File' menu includes 'Exit' and 'Config' options. - 'Help' menu includes an 'About' option displaying version info. - Integrated ConfigPopup and Utils for menu functionality.
1 parent 239123e commit 2e9c7c6

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/main/java/com/georgev22/cosmicjars/CosmicJarsFrame.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.georgev22.cosmicjars;
22

3+
import com.georgev22.cosmicjars.gui.ConfigPopup;
34
import com.georgev22.cosmicjars.gui.HistoryTextField;
45
import com.georgev22.cosmicjars.gui.SmartScroller;
56
import com.georgev22.cosmicjars.helpers.MinecraftServer;
67
import com.georgev22.cosmicjars.utilities.ConsoleOutputHandler;
8+
import com.georgev22.cosmicjars.utilities.Utils;
79
import org.jetbrains.annotations.Contract;
810
import org.jetbrains.annotations.NotNull;
911
import org.jfree.chart.*;
@@ -41,6 +43,46 @@ public CosmicJarsFrame() {
4143
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
4244
setSize(1400, 600);
4345

46+
JMenuBar menuBar = new JMenuBar();
47+
JMenu fileMenu = new JMenu("File");
48+
JMenu helpMenu = new JMenu("Help");
49+
50+
JMenuItem exitItem = new JMenuItem("Exit");
51+
exitItem.addActionListener(e -> System.exit(0));
52+
fileMenu.add(exitItem);
53+
JMenuItem configItem = new JMenuItem("Config");
54+
configItem.addActionListener(e -> ConfigPopup.showConfigPopup());
55+
fileMenu.add(configItem);
56+
57+
JMenuItem aboutItem = new JMenuItem("About");
58+
59+
aboutItem.addActionListener(e -> {
60+
String version = Utils.getManifestValue("Version");
61+
String branch = Utils.getManifestValue("Git-Branch");
62+
String commit = Utils.getManifestValue("Git-Hash");
63+
String repoUrl = Utils.getManifestValue("Git-Repo");
64+
65+
String aboutMessage = String.format(
66+
"""
67+
CosmicJars %s
68+
Developed by GeorgeV22
69+
70+
Branch: %s
71+
Commit: %s
72+
GitHub: %s
73+
74+
Special thanks to JetBrains for their amazing tools!""",
75+
version, branch, commit, repoUrl
76+
);
77+
78+
JOptionPane.showMessageDialog(this, aboutMessage, "About", JOptionPane.INFORMATION_MESSAGE);
79+
});
80+
helpMenu.add(aboutItem);
81+
82+
menuBar.add(fileMenu);
83+
menuBar.add(helpMenu);
84+
setJMenuBar(menuBar);
85+
4486
JPanel mainPanel = new JPanel(new BorderLayout());
4587

4688
JPanel consolePanel = new JPanel(new BorderLayout());

0 commit comments

Comments
 (0)