Add unfinished gui
This commit is contained in:
parent
83f012cf7f
commit
0752f0808b
BIN
files/GUIIcon.png
Normal file
BIN
files/GUIIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
@ -1,10 +1,7 @@
|
|||||||
import net.knarcraft.serverlauncher.server.*;
|
import net.knarcraft.serverlauncher.server.*;
|
||||||
|
import net.knarcraft.serverlauncher.userinterface.GUI;
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
/**
|
|
||||||
* @Version
|
|
||||||
* @Java
|
|
||||||
* @Requires
|
|
||||||
*/
|
|
||||||
//Java 9 required.
|
//Java 9 required.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,6 +14,8 @@ import javax.naming.ConfigurationException;
|
|||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
setup();
|
setup();
|
||||||
|
GUI gui = new GUI();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
@ -27,5 +26,5 @@ public class Main {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Add gui
|
// TODO: Add gui functionality
|
||||||
}
|
}
|
@ -16,9 +16,7 @@ import java.util.ArrayList;
|
|||||||
* @since 0.0.0.1
|
* @since 0.0.0.1
|
||||||
*/
|
*/
|
||||||
public class Server {
|
public class Server {
|
||||||
/**
|
/** Available ram sizes. For GUI dropdown */
|
||||||
* Available ram sizes. For GUI dropdown
|
|
||||||
*/
|
|
||||||
private static final String[] ramList = {"512M", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G", "9G", "10G", "11G", "12G", "13G", "14G", "15G", "16G"};
|
private static final String[] ramList = {"512M", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G", "9G", "10G", "11G", "12G", "13G", "14G", "15G", "16G"};
|
||||||
private static ArrayList<Server> servers = new ArrayList<>();
|
private static ArrayList<Server> servers = new ArrayList<>();
|
||||||
|
|
||||||
@ -56,6 +54,9 @@ public class Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return A representation of the name of a jarfile.
|
||||||
|
*/
|
||||||
private String getType() {
|
private String getType() {
|
||||||
return this.type.getName() + this.serverVersion + ".jar";
|
return this.type.getName() + this.serverVersion + ".jar";
|
||||||
}
|
}
|
||||||
@ -124,7 +125,6 @@ public class Server {
|
|||||||
System.out.println("File was not found.");
|
System.out.println("File was not found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Runtime rt = Runtime.getRuntime();
|
|
||||||
try {
|
try {
|
||||||
ProcessBuilder builder = new ProcessBuilder("java", "-Xmx" + this.maxRam, "-Xms512M", "-Djline.terminal=jline.UnsupportedTerminal", "-Dcom.mojang.eula.agree=true", "-jar", "\"" + this.path + "\\" + this.getType() + "\"");
|
ProcessBuilder builder = new ProcessBuilder("java", "-Xmx" + this.maxRam, "-Xms512M", "-Djline.terminal=jline.UnsupportedTerminal", "-Dcom.mojang.eula.agree=true", "-jar", "\"" + this.path + "\\" + this.getType() + "\"");
|
||||||
builder.directory(new File(this.path));
|
builder.directory(new File(this.path));
|
||||||
|
96
src/net/knarcraft/serverlauncher/userinterface/GUI.java
Normal file
96
src/net/knarcraft/serverlauncher/userinterface/GUI.java
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
package net.knarcraft.serverlauncher.userinterface;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class for creating the gui.
|
||||||
|
*
|
||||||
|
* @author Kristian Knarvik <kristian.knarvik@knett.no>
|
||||||
|
* @version 0.0.0.1
|
||||||
|
* @since 0.0.0.1
|
||||||
|
*/
|
||||||
|
public class GUI {
|
||||||
|
public GUI() {
|
||||||
|
JFrame frame = new JFrame("Minecraft server launcher");
|
||||||
|
ImageIcon img = new ImageIcon("files/GUIIcon.png");
|
||||||
|
frame.setIconImage(img.getImage());
|
||||||
|
frame.setLocation(0,0);
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
JMenuBar menu = new JMenuBar();
|
||||||
|
|
||||||
|
// A menu containing a user's options
|
||||||
|
JMenu optionsMenu = new JMenu("Options");
|
||||||
|
JCheckBoxMenuItem backgroundMode = new JCheckBoxMenuItem("Run in background on exit");
|
||||||
|
JCheckBoxMenuItem delayStartup = new JCheckBoxMenuItem("Delay startup");
|
||||||
|
JCheckBoxMenuItem downloadJars = new JCheckBoxMenuItem("Download Jars");
|
||||||
|
|
||||||
|
// A menu containing helpful information
|
||||||
|
JMenu helpMenu = new JMenu("Help");
|
||||||
|
JMenuItem errors = new JMenuItem("Errors");
|
||||||
|
JMenuItem setup = new JMenuItem("Setup");
|
||||||
|
JMenuItem warning = new JMenuItem("Warning");
|
||||||
|
JMenuItem manualUpdate = new JMenuItem("Manual update");
|
||||||
|
|
||||||
|
// A menu containing various information
|
||||||
|
JMenu infoMenu = new JMenu("Info");
|
||||||
|
JMenu options = new JMenu("Options");
|
||||||
|
JMenu about = new JMenu("About");
|
||||||
|
JMenuItem backgroundModeInfo = new JMenuItem("Run in background on exit");
|
||||||
|
JMenuItem delayStartupInfo = new JMenuItem("Delay Startup");
|
||||||
|
JMenuItem downloadJarsInfo = new JMenuItem("Download jars");
|
||||||
|
JMenuItem aboutAbout = new JMenuItem("About");
|
||||||
|
JMenuItem aboutStory = new JMenuItem("Story");
|
||||||
|
|
||||||
|
// Connects menu items to each other
|
||||||
|
optionsMenu.add(backgroundMode);
|
||||||
|
optionsMenu.add(delayStartup);
|
||||||
|
optionsMenu.add(downloadJars);
|
||||||
|
menu.add(optionsMenu);
|
||||||
|
helpMenu.add(errors);
|
||||||
|
helpMenu.add(setup);
|
||||||
|
helpMenu.add(warning);
|
||||||
|
helpMenu.add(manualUpdate);
|
||||||
|
menu.add(helpMenu);
|
||||||
|
options.add(backgroundModeInfo);
|
||||||
|
options.add(delayStartupInfo);
|
||||||
|
options.add(downloadJarsInfo);
|
||||||
|
infoMenu.add(options);
|
||||||
|
about.add(aboutAbout);
|
||||||
|
about.add(aboutStory);
|
||||||
|
infoMenu.add(about);
|
||||||
|
menu.add(infoMenu);
|
||||||
|
frame.setJMenuBar(menu);
|
||||||
|
|
||||||
|
JTabbedPane tabs = new JTabbedPane(SwingConstants.TOP);
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
JLabel basicControls = new JLabel("Basic controls");
|
||||||
|
JButton sendStart = new JButton("Start servers");
|
||||||
|
JButton sendStop = new JButton("Stop servers");
|
||||||
|
|
||||||
|
panel.add(basicControls);
|
||||||
|
panel.add(sendStart);
|
||||||
|
panel.add(sendStop);
|
||||||
|
tabs.addTab("Basic controls", null, panel, "Basic server controls");
|
||||||
|
frame.add(tabs);
|
||||||
|
|
||||||
|
// TODO: Finish gui
|
||||||
|
|
||||||
|
|
||||||
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
|
||||||
|
Insets insets = frame.getInsets();
|
||||||
|
frame.setSize(450 + 2 * insets.left, 170 + insets.top + insets.bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected JComponent makeTextPanel(String text) {
|
||||||
|
JPanel panel = new JPanel(false);
|
||||||
|
JLabel filler = new JLabel(text);
|
||||||
|
filler.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
panel.setLayout(new GridLayout(1, 1));
|
||||||
|
panel.add(filler);
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user