Improves readability of the server launcher menu code
This commit is contained in:
parent
33795a90a9
commit
429b1fcec0
@ -57,78 +57,18 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
public void initialize() {
|
||||
JMenu mnOptions = new JMenu("Options");
|
||||
menuBar.add(mnOptions);
|
||||
|
||||
runInBackgroundCheckBoxMenuItem = new JCheckBoxMenuItem("Run in background on exit");
|
||||
mnOptions.add(runInBackgroundCheckBoxMenuItem);
|
||||
runInBackgroundCheckBoxMenuItem.addActionListener(this);
|
||||
|
||||
delayStartupCheckBoxMenuItem = new JCheckBoxMenuItem("Delay Startup");
|
||||
mnOptions.add(delayStartupCheckBoxMenuItem);
|
||||
delayStartupCheckBoxMenuItem.addActionListener(this);
|
||||
|
||||
downloadJarsCheckBoxMenuItem = new JCheckBoxMenuItem("Download jars");
|
||||
mnOptions.add(downloadJarsCheckBoxMenuItem);
|
||||
downloadJarsCheckBoxMenuItem.addActionListener(this);
|
||||
|
||||
javaCommandMenuItem = new JMenuItem("Java command");
|
||||
mnOptions.add(javaCommandMenuItem);
|
||||
javaCommandMenuItem.addActionListener(this);
|
||||
|
||||
oldJavaCommandMenuItem = new JMenuItem("Old Java command");
|
||||
mnOptions.add(oldJavaCommandMenuItem);
|
||||
oldJavaCommandMenuItem.addActionListener(this);
|
||||
generateOptionsMenuItems(mnOptions);
|
||||
|
||||
JMenu mnHelp = new JMenu("Help");
|
||||
menuBar.add(mnHelp);
|
||||
|
||||
errorsMenuItem = new JMenuItem("Errors");
|
||||
mnHelp.add(errorsMenuItem);
|
||||
errorsMenuItem.addActionListener(this);
|
||||
|
||||
setupMenuItem = new JMenuItem("Setup");
|
||||
mnHelp.add(setupMenuItem);
|
||||
setupMenuItem.addActionListener(this);
|
||||
|
||||
manualUpdateMenuItem = new JMenuItem("Manual update");
|
||||
mnHelp.add(manualUpdateMenuItem);
|
||||
manualUpdateMenuItem.addActionListener(this);
|
||||
errorsMenuItem = createMenuItem("Errors", mnHelp);
|
||||
setupMenuItem = createMenuItem("Setup", mnHelp);
|
||||
manualUpdateMenuItem = createMenuItem("Manual update", mnHelp);
|
||||
|
||||
JMenu mnInfo = new JMenu("Info");
|
||||
menuBar.add(mnInfo);
|
||||
|
||||
JMenu mnOptionsInfo = new JMenu("Options");
|
||||
mnInfo.add(mnOptionsInfo);
|
||||
|
||||
runInBackgroundMenuItem = new JMenuItem("Run in background on exit");
|
||||
mnOptionsInfo.add(runInBackgroundMenuItem);
|
||||
runInBackgroundMenuItem.addActionListener(this);
|
||||
|
||||
delayStartupMenuItem = new JMenuItem("Delay Startup");
|
||||
mnOptionsInfo.add(delayStartupMenuItem);
|
||||
delayStartupMenuItem.addActionListener(this);
|
||||
|
||||
downloadJarsMenuItem = new JMenuItem("Download jars");
|
||||
mnOptionsInfo.add(downloadJarsMenuItem);
|
||||
downloadJarsMenuItem.addActionListener(this);
|
||||
|
||||
javaCommandInfoMenuItem = new JMenuItem("Java command");
|
||||
mnOptionsInfo.add(javaCommandInfoMenuItem);
|
||||
javaCommandInfoMenuItem.addActionListener(this);
|
||||
|
||||
oldJavaCommandInfoMenuItem = new JMenuItem("Old Java command");
|
||||
mnOptionsInfo.add(oldJavaCommandInfoMenuItem);
|
||||
oldJavaCommandInfoMenuItem.addActionListener(this);
|
||||
|
||||
JMenu mnAbout = new JMenu("About");
|
||||
mnInfo.add(mnAbout);
|
||||
|
||||
aboutMenuItem = new JMenuItem("About");
|
||||
mnAbout.add(aboutMenuItem);
|
||||
aboutMenuItem.addActionListener(this);
|
||||
|
||||
storyMenuItem = new JMenuItem("Story");
|
||||
mnAbout.add(storyMenuItem);
|
||||
storyMenuItem.addActionListener(this);
|
||||
generateInfoMenuItems(mnInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,6 +116,69 @@ public class ServerLauncherMenu implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the children of the options menu
|
||||
*
|
||||
* @param mnOptions <p>A reference to the options menu</p>
|
||||
*/
|
||||
private void generateOptionsMenuItems(JMenu mnOptions) {
|
||||
runInBackgroundCheckBoxMenuItem = createCheckBoxMenuItem("Run in background on exit", mnOptions);
|
||||
delayStartupCheckBoxMenuItem = createCheckBoxMenuItem("Delay Startup", mnOptions);
|
||||
downloadJarsCheckBoxMenuItem = createCheckBoxMenuItem("Download jars", mnOptions);
|
||||
javaCommandMenuItem = createMenuItem("Java command", mnOptions);
|
||||
oldJavaCommandMenuItem = createMenuItem("Old Java command", mnOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the children of the info menu
|
||||
*
|
||||
* @param mnInfo <p>A reference to the info menu</p>
|
||||
*/
|
||||
private void generateInfoMenuItems(JMenu mnInfo) {
|
||||
JMenu mnOptionsInfo = new JMenu("Options");
|
||||
mnInfo.add(mnOptionsInfo);
|
||||
|
||||
runInBackgroundMenuItem = createMenuItem("Run in background on exit", mnOptionsInfo);
|
||||
delayStartupMenuItem = createMenuItem("Delay Startup", mnOptionsInfo);
|
||||
downloadJarsMenuItem = createMenuItem("Download jars", mnOptionsInfo);
|
||||
javaCommandInfoMenuItem = createMenuItem("Java command", mnOptionsInfo);
|
||||
oldJavaCommandInfoMenuItem = createMenuItem("Old Java command", mnOptionsInfo);
|
||||
|
||||
JMenu mnAbout = new JMenu("About");
|
||||
mnInfo.add(mnAbout);
|
||||
|
||||
aboutMenuItem = createMenuItem("About", mnAbout);
|
||||
storyMenuItem = createMenuItem("Story", mnAbout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a checkbox menu item
|
||||
*
|
||||
* @param itemName <p>The name of the new checkbox item</p>
|
||||
* @param parent <p>The parent menu the item belongs to</p>
|
||||
* @return <p>The created checkbox menu item</p>
|
||||
*/
|
||||
private JCheckBoxMenuItem createCheckBoxMenuItem(String itemName, JMenu parent) {
|
||||
JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(itemName);
|
||||
parent.add(menuItem);
|
||||
menuItem.addActionListener(this);
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a menu item
|
||||
*
|
||||
* @param itemName <p>The name of the new item</p>
|
||||
* @param parent <p>The parent menu the item belongs to</p>
|
||||
* @return <p>The created menu item</p>
|
||||
*/
|
||||
private JMenuItem createMenuItem(String itemName, JMenu parent) {
|
||||
JMenuItem menuItem = new JMenuItem(itemName);
|
||||
parent.add(menuItem);
|
||||
menuItem.addActionListener(this);
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the user for the new Java path
|
||||
* @param old <p>Whether asking for the path to the old java version</p>
|
||||
|
@ -6,5 +6,5 @@ aboutText=This software was created to start and manage several servers simultan
|
||||
infoURL=https://archive.knarcraft.net/Scripts/BungeeMinecraftServerLauncherInfo/
|
||||
manualUpdateURL=https://git.knarcraft.net/KnarCraft/Minecraft-Server-Launcher/releases
|
||||
storyURL=https://archive.knarcraft.net/Scripts/BungeeMinecraftServerLauncherStory/
|
||||
javaCommandText=This option allows you to set a custom command/path to the Java executable used for Minecraft 1.17 and above. If "java" is currently pointing to Java 8, you can use this to set a custom one for running new Minecraft servers and BuildTools.
|
||||
oldJavaCommandText=This option allows you to set a custom command/path to the Java executable used for Minecraft 1.16 and below. If "java" is currently pointing to Java 16, you can use this to set a custom one for running old Minecraft servers.
|
||||
javaCommandText=This option allows you to set a custom command/path to the Java executable used for Minecraft 1.17 and above._BREAK_If "java" is currently pointing to Java 8, you can use this to set a custom one for running new Minecraft servers and BuildTools.
|
||||
oldJavaCommandText=This option allows you to set a custom command/path to the Java executable used for Minecraft 1.16 and below._BREAK_If "java" is currently pointing to Java 16, you can use this to set a custom one for running old Minecraft servers.
|
Can't render this file because it contains an unexpected character in line 9 and column 130.
|
Loading…
Reference in New Issue
Block a user