From 0752f0808baa105a57a25816852a3bbbac1183b2 Mon Sep 17 00:00:00 2001 From: Kristian Knarvik Date: Fri, 26 Jan 2018 20:26:16 +0100 Subject: [PATCH] Add unfinished gui --- files/GUIIcon.png | Bin 0 -> 2768 bytes src/Main.java | 11 +- .../serverlauncher/server/Server.java | 8 +- .../serverlauncher/userinterface/GUI.java | 96 ++++++++++++++++++ 4 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 files/GUIIcon.png create mode 100644 src/net/knarcraft/serverlauncher/userinterface/GUI.java diff --git a/files/GUIIcon.png b/files/GUIIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..1b5f48a4236df8e35c52a46f2145f9a7a8e0d284 GIT binary patch literal 2768 zcmXw5c{r3^8-JeRVa%W*#&Sth))=BBBQay&vJ=x_Mkt}sWGtyCSw?!x8fBNF1%sEY z4Mv358gE_^Q`WCUBwOm6-tYSUxX(Gi`#RUT&V8Tz{+(ZvgPny4N)`nGfQXf)sS|I8 ze;ZPOH*ySVy}Sv$>||jKRP@U&@&Nxi(kT)ERNY1Ypg}w=6k_Rd8305%zYXlVROZWb z%FxZ+>CTt@=?q$!9}q$dxJcK$=tsxtXliL5(f*1H$OHfs(aMzM65+L!7aiiVF4=Xx zDH4P1z6i$!iKhkW3f*-uytTz=NU^?|#xg?aytCuw zv)v0=oQw8DU=~kY7%o3^JPgA%mZVOq@w|)Uwdw?BND)%&Y#)k;y9WkT1jRHZKC}hNv2Y76%Q^ERMt$>1Oyp(wfkqDX z!-RExhpFDiRvUD=lZv5QKYRC9lE_T4XsU+=Pt!h0Vl1Xq4uSUzEE z$EsgFg6q#jmcNk$$&ZxFRHsxPE467z5Zinkf~=Xx61`}u~J z4G(R7luxFBkMU)(BR_;KyHBB0K8KPLb6q57cP#v~WX5MaZjHnoUgde+n--k3Wk+n)kn0D?ijd=5ci7bYIz{p@H4K`C5N=ugO*Gnm#89qgS@94mnDN zW-=vbs&*X1g<~{o+&cRoRHzf%(iK>l+cc0&?R2p{3m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%9z^DoAff;P9{oe4N1uYY~`1XbpkBu;q`pSEAU+&W{|G0c2nnJ?QK&R-Fu!$+N* zLieo{q6p#!5k@}!5txBf$E2FFZnRX9`XguB#XLJYFJJ=C^*)g5lU%C zl*L&C=iH8TloAU6P!}7Ye*5?4G0kHjxk$RolHOF8P=Oh~iqN^?ew)px>{QN9nvX1sz(;id%2eab9F( zU3v1&8b2}S3kIxLHA(qgt|WLx@XF=Z@Gm$5UBk!W5+(*!@~z-B_5oKm$+4&28hOR5i@DOFYz(~Lh|bQCWMonPlTvE zLczjv#(F{xfchy#qGQ29%UYDlK)Y9^MqIPp_@vLUK+gxP|;Ok?*s+a(4ItdvUd9XfLoU41uOL6 z3GeGkrlik*C`(M2_wn-VcJBsL>RZ*$`Sd%zY{{d3G)Z27zeyu>@ZUgq@hr@3@%})6 zcR(=>%6@rXz9T#c-P1KBsPL4PTno873Vg2%Ume@kt4=RJ1gFh5U3YE?lIlaBcyZeP z#}!YLi3JkQT*5{g>BCjTtSM(F%k*S6l|`{Tj|K4K$5wsTho^!S9HUqtM)!@r3^()7 zU0fn6z9Of28C`wdc=yZPt)mZ5ZcUtrP>Iw3d6k+7F;`fCm^@ETa1f>uzmW_5!TJi!TA Mnc10E7*k{a3u~**7ytkO literal 0 HcmV?d00001 diff --git a/src/Main.java b/src/Main.java index 09286cf..7ba204f 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,10 +1,7 @@ import net.knarcraft.serverlauncher.server.*; +import net.knarcraft.serverlauncher.userinterface.GUI; + import javax.naming.ConfigurationException; -/** - * @Version - * @Java - * @Requires - */ //Java 9 required. /** @@ -17,6 +14,8 @@ import javax.naming.ConfigurationException; public class Main { public static void main(String[] args) { setup(); + GUI gui = new GUI(); + } public static void setup() { @@ -27,5 +26,5 @@ public class Main { System.exit(1); } } - // TODO: Add gui + // TODO: Add gui functionality } \ No newline at end of file diff --git a/src/net/knarcraft/serverlauncher/server/Server.java b/src/net/knarcraft/serverlauncher/server/Server.java index 977342f..85e348e 100644 --- a/src/net/knarcraft/serverlauncher/server/Server.java +++ b/src/net/knarcraft/serverlauncher/server/Server.java @@ -16,9 +16,7 @@ import java.util.ArrayList; * @since 0.0.0.1 */ 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 ArrayList servers = new ArrayList<>(); @@ -56,6 +54,9 @@ public class Server { } } + /** + * @return A representation of the name of a jarfile. + */ private String getType() { return this.type.getName() + this.serverVersion + ".jar"; } @@ -124,7 +125,6 @@ public class Server { System.out.println("File was not found."); return; } - //Runtime rt = Runtime.getRuntime(); try { 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)); diff --git a/src/net/knarcraft/serverlauncher/userinterface/GUI.java b/src/net/knarcraft/serverlauncher/userinterface/GUI.java new file mode 100644 index 0000000..5a8e225 --- /dev/null +++ b/src/net/knarcraft/serverlauncher/userinterface/GUI.java @@ -0,0 +1,96 @@ +package net.knarcraft.serverlauncher.userinterface; + +import javax.swing.*; +import java.awt.*; + +/** + * A class for creating the gui. + * + * @author Kristian Knarvik + * @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; + } +}