Using pack() for scaling

This commit is contained in:
Kristian Knarvik 2018-01-31 17:40:28 +01:00
parent 749af701a8
commit 30263d7753
9 changed files with 114 additions and 75 deletions

View File

@ -24,7 +24,7 @@ class Main {
try { try {
setup(); setup();
new GUI(); new GUI();
//new ServerConsoles(); new ServerConsoles();
Profile.addProfile("Default"); Profile.addProfile("Default");
//TODO: replace with profiles loading generating a default profile if empty. //TODO: replace with profiles loading generating a default profile if empty.

View File

@ -0,0 +1,37 @@
package net.knarcraft.serverlauncher.profile;
import net.knarcraft.serverlauncher.server.Server;
import net.knarcraft.serverlauncher.userinterface.GUI;
import net.knarcraft.serverlauncher.userinterface.ServerConsoles;
import net.knarcraft.serverlauncher.userinterface.ServerTab;
import net.knarcraft.serverlauncher.userinterface.Console;
public class Collection {
private Server server;
private ServerTab serverTab;
private Console serverConsole;
private String name;
public Collection(String name) {
this.serverTab = new ServerTab(name);
this.server = new Server(name, GUI.getGUI(), this.serverTab);
this.serverConsole = ServerConsoles.getGUI().addTab(name);
}
public String getName() {
return this.name;
}
public Server getServer() {
return this.server;
}
public ServerTab getServerTab() {
return this.serverTab;
}
public Console getServerConsole() {
return this.serverConsole;
}
}

View File

@ -19,7 +19,7 @@ import java.util.ArrayList;
public class Profile { public class Profile {
private static final ArrayList<Profile> profiles = new ArrayList<>(); private static final ArrayList<Profile> profiles = new ArrayList<>();
private final ArrayList<Server> servers; private final ArrayList<Collection> collections;
private final String name; private final String name;
private boolean runInBackground; private boolean runInBackground;
private int delayStartup; private int delayStartup;
@ -30,7 +30,7 @@ public class Profile {
private String bungeeVersion; private String bungeeVersion;
private Profile(String name) { private Profile(String name) {
this.servers = new ArrayList<>(); this.collections = new ArrayList<>();
this.name = name; this.name = name;
this.runInBackground = false; this.runInBackground = false;
this.delayStartup = 0; this.delayStartup = 0;
@ -38,34 +38,38 @@ public class Profile {
profiles.add(this); profiles.add(this);
} }
public void addServer(Server server) { public void addCollection(String name) {
this.servers.add(server); if (!collectionExists(name)) {
collections.add(new Collection(name));
} else {
JOptionPane.showMessageDialog(null, "A server name must my unique and not empty.", "Error", JOptionPane.ERROR_MESSAGE);
}
} }
public void removeServer(int i) { public void removeCollection(int i) {
this.servers.remove(i); this.collections.remove(i);
} }
private Server getServer(String name) { private Collection getCollection(String name) {
for (Server server : this.servers) { for (Collection collection : this.collections) {
if (server.getName().equals(name)) { if (collection.getName().equals(name)) {
return server; return collection;
} }
} }
return null; return null;
} }
public boolean serverExists(String name) { public boolean collectionExists(String name) {
for (Server server : this.servers) { for (Collection collection : this.collections) {
if (server.getName().equals(name)) { if (collection.getName().equals(name)) {
return true; return true;
} }
} }
return false; return false;
} }
public ArrayList<Server> getServers() { public ArrayList<Collection> getCollections() {
return this.servers; return this.collections;
} }
public static void addProfile(String name) { public static void addProfile(String name) {
@ -122,15 +126,15 @@ public class Profile {
public void sendCommand(String serverName, String command) { public void sendCommand(String serverName, String command) {
if (serverName.equals("All")) { if (serverName.equals("All")) {
for (Server server : this.servers) { for (Collection collection : this.collections) {
try { try {
server.sendCommand(command); collection.getServer().sendCommand(command);
} catch (IOException e) { } catch (IOException e) {
JOptionPane.showMessageDialog(null, "Server " + server.getName() + " caused an exception.", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, "Server " + collection.getServer().getName() + " caused an exception.", "Error", JOptionPane.ERROR_MESSAGE);
} }
} }
} else { } else {
Server target = getServer(serverName); Server target = getCollection(serverName).getServer();
if (target != null) { if (target != null) {
try { try {
target.sendCommand(command); target.sendCommand(command);
@ -176,10 +180,10 @@ public class Profile {
} }
} }
public void save(ArrayList<ServerTab> serverTabs) { public void save() {
for (int i = 0; i < this.servers.size(); i++) { for (int i = 0; i < this.collections.size(); i++) {
Server server = servers.get(i); Server server = collections.get(i).getServer();
ServerTab serverTab = serverTabs.get(i); ServerTab serverTab = collections.get(i).getServerTab();
server.setPath(serverTab.getPath()); server.setPath(serverTab.getPath());
server.setMaxRam(serverTab.getMaxRam()); server.setMaxRam(serverTab.getMaxRam());
server.setType(ServerType.getByName(serverTab.getType())); server.setType(ServerType.getByName(serverTab.getType()));

View File

@ -1,7 +1,9 @@
package net.knarcraft.serverlauncher.server; package net.knarcraft.serverlauncher.server;
import net.knarcraft.serverlauncher.profile.Collection;
import net.knarcraft.serverlauncher.profile.Profile; import net.knarcraft.serverlauncher.profile.Profile;
import net.knarcraft.serverlauncher.userinterface.GUI; import net.knarcraft.serverlauncher.userinterface.GUI;
import net.knarcraft.serverlauncher.userinterface.ServerTab;
import java.io.*; import java.io.*;
import java.net.URL; import java.net.URL;
@ -33,7 +35,7 @@ public class Server {
private Process process; private Process process;
private BufferedWriter writer; private BufferedWriter writer;
public Server(String name, GUI window) { public Server(String name, GUI window, ServerTab serverTab) {
this.name = name; this.name = name;
this.path = ""; this.path = "";
this.enabled = false; this.enabled = false;
@ -42,8 +44,7 @@ public class Server {
this.serverVersion = null; this.serverVersion = null;
this.maxRam = ramList[0]; this.maxRam = ramList[0];
this.process = null; this.process = null;
GUI.getGUI().currentProfile().addServer(this); window.addServer(serverTab);
window.addServer(name);
} }
public void addPlayer(String name) { public void addPlayer(String name) {
@ -110,15 +111,15 @@ public class Server {
} }
public static void stop() throws IOException { public static void stop() throws IOException {
for (Server server : GUI.getGUI().currentProfile().getServers()) { for (Collection collection : GUI.getGUI().currentProfile().getCollections()) {
if (server.writer != null) { if (collection.getServer().writer != null) {
if (server.type.getName().equals("Bungee")) { if (collection.getServer().type.getName().equals("Bungee")) {
server.writer.write("end\n"); collection.getServer().writer.write("end\n");
} else { } else {
server.writer.write("stop\n"); collection.getServer().writer.write("stop\n");
} }
server.writer.flush(); collection.getServer().writer.flush();
server.writer = null; collection.getServer().writer = null;
} }
} }
} }
@ -144,8 +145,8 @@ public class Server {
*/ */
public static void startServers() { public static void startServers() {
GUI.getGUI().setStatus("Starting servers"); GUI.getGUI().setStatus("Starting servers");
for (Server server : GUI.getGUI().currentProfile().getServers()) { for (Collection collection : GUI.getGUI().currentProfile().getCollections()) {
if (!server.run()) { if (!collection.getServer().run()) {
GUI.getGUI().setStatus("An error occurred. Start aborted"); GUI.getGUI().setStatus("An error occurred. Start aborted");
} }
} }

View File

@ -11,7 +11,7 @@ import java.awt.*;
* @version 0.0.0.1 * @version 0.0.0.1
* @since 0.0.0.1 * @since 0.0.0.1
*/ */
class Console { public class Console {
private final JTextField textInput; private final JTextField textInput;
private final JTextArea textOutput; private final JTextArea textOutput;
@ -19,7 +19,7 @@ class Console {
this.textOutput.setText(text); this.textOutput.setText(text);
} }
Console(JTabbedPane tab, String name) { public Console(JTabbedPane tab, String name) {
JPanel panel = new JPanel(); JPanel panel = new JPanel();
tab.addTab(name, null, panel, null); tab.addTab(name, null, panel, null);
panel.setLayout(new BorderLayout(0, 0)); panel.setLayout(new BorderLayout(0, 0));

View File

@ -1,10 +1,12 @@
package net.knarcraft.serverlauncher.userinterface; package net.knarcraft.serverlauncher.userinterface;
import net.knarcraft.serverlauncher.profile.Collection;
import net.knarcraft.serverlauncher.server.Server; import net.knarcraft.serverlauncher.server.Server;
import net.knarcraft.serverlauncher.profile.Profile; import net.knarcraft.serverlauncher.profile.Profile;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
@ -107,7 +109,7 @@ public class GUI implements ActionListener {
for (int i = 0; i < this.serverTabs.size(); i++) { for (int i = 0; i < this.serverTabs.size(); i++) {
if(this.serverTabs.get(i) == tab) { if(this.serverTabs.get(i) == tab) {
serversPane.remove(i); serversPane.remove(i);
currentProfile().removeServer(i); currentProfile().removeCollection(i);
this.serverTabs.remove(i); this.serverTabs.remove(i);
i = serverTabs.size(); i = serverTabs.size();
} }
@ -119,14 +121,13 @@ public class GUI implements ActionListener {
* Initialize the contents of the frame. * Initialize the contents of the frame.
*/ */
private void initialize() { private void initialize() {
try { /*try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | UnsupportedLookAndFeelException | InstantiationException | IllegalAccessException e) { } catch (ClassNotFoundException | UnsupportedLookAndFeelException | InstantiationException | IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }*/
frame = new JFrame("Minecraft server launcher"); frame = new JFrame("Minecraft server launcher");
frame.setBounds(100, 100, 470, 219);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setResizable(false); frame.setResizable(false);
ImageIcon img; ImageIcon img;
@ -204,7 +205,6 @@ public class GUI implements ActionListener {
mntmStory = new JMenuItem("Story"); mntmStory = new JMenuItem("Story");
mnAbout.add(mntmStory); mnAbout.add(mntmStory);
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.X_AXIS));
mntmStory.addActionListener(this); mntmStory.addActionListener(this);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
@ -221,8 +221,7 @@ public class GUI implements ActionListener {
btnStartServer = new JButton("Start servers"); btnStartServer = new JButton("Start servers");
sl_panel.putConstraint(SpringLayout.WEST, lblBasicControls, 0, SpringLayout.WEST, btnStartServer); sl_panel.putConstraint(SpringLayout.WEST, lblBasicControls, 0, SpringLayout.WEST, btnStartServer);
sl_panel.putConstraint(SpringLayout.SOUTH, lblBasicControls, -6, SpringLayout.NORTH, btnStartServer); sl_panel.putConstraint(SpringLayout.NORTH, btnStartServer, 6, SpringLayout.SOUTH, lblBasicControls);
sl_panel.putConstraint(SpringLayout.NORTH, btnStartServer, 30, SpringLayout.NORTH, panelBasic);
sl_panel.putConstraint(SpringLayout.WEST, btnStartServer, 10, SpringLayout.WEST, panelBasic); sl_panel.putConstraint(SpringLayout.WEST, btnStartServer, 10, SpringLayout.WEST, panelBasic);
panelBasic.add(btnStartServer); panelBasic.add(btnStartServer);
btnStartServer.addActionListener(this); btnStartServer.addActionListener(this);
@ -251,15 +250,16 @@ public class GUI implements ActionListener {
delProfile.addActionListener(this); delProfile.addActionListener(this);
profiles = new JComboBox<>(); profiles = new JComboBox<>();
sl_panel.putConstraint(SpringLayout.NORTH, profiles, 1, SpringLayout.NORTH, addProfile); sl_panel.putConstraint(SpringLayout.NORTH, profiles, 0, SpringLayout.NORTH, addProfile);
sl_panel.putConstraint(SpringLayout.WEST, profiles, 6, SpringLayout.EAST, delProfile); sl_panel.putConstraint(SpringLayout.WEST, profiles, 6, SpringLayout.EAST, delProfile);
sl_panel.putConstraint(SpringLayout.EAST, profiles, 124, SpringLayout.EAST, delProfile); sl_panel.putConstraint(SpringLayout.EAST, profiles, 124, SpringLayout.EAST, delProfile);
panelBasic.add(profiles); panelBasic.add(profiles);
profiles.addActionListener(this); profiles.addActionListener(this);
sl_panel.putConstraint(SpringLayout.NORTH, lblStatuslabel, 8, SpringLayout.SOUTH, addProfile); sl_panel.putConstraint(SpringLayout.NORTH, lblStatuslabel, 6, SpringLayout.SOUTH, addProfile);
sl_panel.putConstraint(SpringLayout.SOUTH, lblStatuslabel, -10, SpringLayout.SOUTH, panelBasic);
sl_panel.putConstraint(SpringLayout.WEST, lblStatuslabel, 10, SpringLayout.WEST, panelBasic); sl_panel.putConstraint(SpringLayout.WEST, lblStatuslabel, 10, SpringLayout.WEST, panelBasic);
sl_panel.putConstraint(SpringLayout.EAST, lblStatuslabel, 386, SpringLayout.WEST, panelBasic); sl_panel.putConstraint(SpringLayout.EAST, lblStatuslabel, -10, SpringLayout.EAST, panelBasic);
panelBasic.add(lblStatuslabel); panelBasic.add(lblStatuslabel);
addServer = new JButton("Add server"); addServer = new JButton("Add server");
@ -291,15 +291,15 @@ public class GUI implements ActionListener {
btnKick = new JButton("Kick"); btnKick = new JButton("Kick");
sl_panel_1.putConstraint(SpringLayout.NORTH, btnKick, 10, SpringLayout.NORTH, controlServers); sl_panel_1.putConstraint(SpringLayout.NORTH, btnKick, 10, SpringLayout.NORTH, controlServers);
sl_panel_1.putConstraint(SpringLayout.WEST, btnKick, 6, SpringLayout.EAST, targetServer); sl_panel_1.putConstraint(SpringLayout.WEST, btnKick, 6, SpringLayout.EAST, targetServer);
sl_panel_1.putConstraint(SpringLayout.EAST, btnKick, 124, SpringLayout.WEST, btnKick); sl_panel_1.putConstraint(SpringLayout.EAST, btnKick, 104, SpringLayout.WEST, btnKick);
sl_panel_1.putConstraint(SpringLayout.SOUTH, targetServer, 0, SpringLayout.SOUTH, btnKick); sl_panel_1.putConstraint(SpringLayout.SOUTH, targetServer, 0, SpringLayout.SOUTH, btnKick);
controlServers.add(btnKick); controlServers.add(btnKick);
btnKick.addActionListener(this); btnKick.addActionListener(this);
btnBan = new JButton("Ban"); btnBan = new JButton("Ban");
sl_panel_1.putConstraint(SpringLayout.NORTH, btnBan, 5, SpringLayout.SOUTH, btnKick); sl_panel_1.putConstraint(SpringLayout.NORTH, btnBan, 6, SpringLayout.SOUTH, btnKick);
sl_panel_1.putConstraint(SpringLayout.WEST, btnBan, 6, SpringLayout.EAST, targetPlayer); sl_panel_1.putConstraint(SpringLayout.WEST, btnBan, 6, SpringLayout.EAST, targetPlayer);
sl_panel_1.putConstraint(SpringLayout.EAST, btnBan, 124, SpringLayout.WEST, btnBan); sl_panel_1.putConstraint(SpringLayout.EAST, btnBan, 104, SpringLayout.WEST, btnBan);
sl_panel_1.putConstraint(SpringLayout.SOUTH, targetPlayer, 0, SpringLayout.SOUTH, btnBan); sl_panel_1.putConstraint(SpringLayout.SOUTH, targetPlayer, 0, SpringLayout.SOUTH, btnBan);
controlServers.add(btnBan); controlServers.add(btnBan);
btnBan.addActionListener(this); btnBan.addActionListener(this);
@ -307,7 +307,6 @@ public class GUI implements ActionListener {
btnOp = new JButton("OP"); btnOp = new JButton("OP");
sl_panel_1.putConstraint(SpringLayout.NORTH, btnOp, 10, SpringLayout.NORTH, controlServers); sl_panel_1.putConstraint(SpringLayout.NORTH, btnOp, 10, SpringLayout.NORTH, controlServers);
sl_panel_1.putConstraint(SpringLayout.WEST, btnOp, 6, SpringLayout.EAST, btnKick); sl_panel_1.putConstraint(SpringLayout.WEST, btnOp, 6, SpringLayout.EAST, btnKick);
//sl_panel_1.putConstraint(SpringLayout.SOUTH, btnOp, 32, SpringLayout.NORTH, controlServers);
sl_panel_1.putConstraint(SpringLayout.EAST, btnOp, -10, SpringLayout.EAST, controlServers); sl_panel_1.putConstraint(SpringLayout.EAST, btnOp, -10, SpringLayout.EAST, controlServers);
controlServers.add(btnOp); controlServers.add(btnOp);
btnOp.addActionListener(this); btnOp.addActionListener(this);
@ -353,7 +352,8 @@ public class GUI implements ActionListener {
sl_panel_1.putConstraint(SpringLayout.NORTH, customCommand, 6, SpringLayout.SOUTH, btnSaveserver); sl_panel_1.putConstraint(SpringLayout.NORTH, customCommand, 6, SpringLayout.SOUTH, btnSaveserver);
sl_panel_1.putConstraint(SpringLayout.NORTH, btnSaveserver, 6, SpringLayout.SOUTH, btnBan); sl_panel_1.putConstraint(SpringLayout.NORTH, btnSaveserver, 6, SpringLayout.SOUTH, btnBan);
sl_panel_1.putConstraint(SpringLayout.WEST, btnSaveserver, 0, SpringLayout.WEST, btnKick); sl_panel_1.putConstraint(SpringLayout.WEST, btnSaveserver, 0, SpringLayout.WEST, btnKick);
sl_panel_1.putConstraint(SpringLayout.EAST, btnSaveserver, 120, SpringLayout.WEST, btnKick); sl_panel_1.putConstraint(SpringLayout.EAST, btnSaveserver, 104, SpringLayout.WEST, btnKick);
sl_panel_1.putConstraint(SpringLayout.EAST, btnSaveserver, 104, SpringLayout.WEST, btnKick);
controlServers.add(btnSaveserver); controlServers.add(btnSaveserver);
btnSaveserver.addActionListener(this); btnSaveserver.addActionListener(this);
@ -386,13 +386,14 @@ public class GUI implements ActionListener {
this.serversPane = tabbedPane_1; this.serversPane = tabbedPane_1;
tabbedPane_1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); tabbedPane_1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
frame.setPreferredSize(frame.getPreferredSize()); frame.getContentPane().setPreferredSize(new Dimension(440, 170));
frame.validate(); frame.validate();
frame.pack();
frame.setVisible(true); frame.setVisible(true);
} }
public void addServer(String name) { public void addServer(ServerTab serverTab) {
serverTabs.add(new ServerTab(name)); serverTabs.add(serverTab);
} }
@Override @Override
@ -421,11 +422,11 @@ public class GUI implements ActionListener {
} else if (e.getSource() == mntmRunInBackground) { } else if (e.getSource() == mntmRunInBackground) {
JOptionPane.showMessageDialog(null, runInBackgroundText, "Run in background", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, runInBackgroundText, "Run in background", JOptionPane.INFORMATION_MESSAGE);
} else if (e.getSource() == mntmDelayStartup) { } else if (e.getSource() == mntmDelayStartup) {
JOptionPane.showMessageDialog(null, delayStartupText, "Run in background", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, delayStartupText, "Delay startup", JOptionPane.INFORMATION_MESSAGE);
} else if (e.getSource() == mntmDownloadJars) { } else if (e.getSource() == mntmDownloadJars) {
JOptionPane.showMessageDialog(null, downloadJarsText, "Run in background", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, downloadJarsText, "Download jars", JOptionPane.INFORMATION_MESSAGE);
} else if (e.getSource() == mntmAbout) { } else if (e.getSource() == mntmAbout) {
JOptionPane.showMessageDialog(null, aboutText, "Run in background", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, aboutText, "About", JOptionPane.INFORMATION_MESSAGE);
} else if (e.getSource() == mntmStory) { } else if (e.getSource() == mntmStory) {
goToURL("https://knarcraft.net/Bungeeminecraftserverlauncher/Story/"); goToURL("https://knarcraft.net/Bungeeminecraftserverlauncher/Story/");
} else if (e.getSource() == btnStartServer) { } else if (e.getSource() == btnStartServer) {
@ -435,11 +436,7 @@ public class GUI implements ActionListener {
stop(); stop();
} else if (e.getSource() == addServer) { } else if (e.getSource() == addServer) {
String serverName = JOptionPane.showInputDialog("Name of server: "); String serverName = JOptionPane.showInputDialog("Name of server: ");
if (!serverName.equals("") && !currentProfile().serverExists(serverName)) { this.currentProfile().addCollection(serverName);
new Server(serverName, this);
} else {
JOptionPane.showMessageDialog(null, "A server name must my unique and not empty.", "Error", JOptionPane.ERROR_MESSAGE);
}
} else if (e.getSource() == backup) { } else if (e.getSource() == backup) {
backup(); backup();
} else if (e.getSource() == addProfile) { } else if (e.getSource() == addProfile) {
@ -479,6 +476,7 @@ public class GUI implements ActionListener {
} }
} else if (e.getSource() == btnServerConsoles) { } else if (e.getSource() == btnServerConsoles) {
//TODO: Make server consoles window, and toggle visibility on this action. //TODO: Make server consoles window, and toggle visibility on this action.
ServerConsoles.getGUI().show();
} }
} }
@ -486,7 +484,7 @@ public class GUI implements ActionListener {
* Reads all combo boxes, updates variables and saves to disk * Reads all combo boxes, updates variables and saves to disk
*/ */
private void save() { private void save() {
currentProfile().save(serverTabs); currentProfile().save();
} }
/** /**
@ -562,10 +560,10 @@ public class GUI implements ActionListener {
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
File path = chooser.getSelectedFile(); File path = chooser.getSelectedFile();
for (Server server : currentProfile().getServers()) { for (Collection collection : currentProfile().getCollections()) {
if (!server.getPath().equals("") && server.isEnabled()) { if (!collection.getServer().getPath().equals("") && collection.getServer().isEnabled()) {
String name = server.getName(); String name = collection.getServer().getName();
File srcFolder = new File(server.getPath()); File srcFolder = new File(collection.getServer().getPath());
File destFolder = new File(path, name); File destFolder = new File(path, name);
if (!destFolder.exists()) { if (!destFolder.exists()) {
if (destFolder.mkdirs()) { if (destFolder.mkdirs()) {

View File

@ -16,7 +16,6 @@ import java.util.ArrayList;
*/ */
public class ServerConsoles { public class ServerConsoles {
private static ServerConsoles serverConsoles; private static ServerConsoles serverConsoles;
private static ArrayList<Console> consoles = new ArrayList<>();
private final JFrame frame; private final JFrame frame;
private final JTabbedPane consolesTab; private final JTabbedPane consolesTab;
@ -28,7 +27,6 @@ public class ServerConsoles {
consolesTab = new JTabbedPane(JTabbedPane.TOP); consolesTab = new JTabbedPane(JTabbedPane.TOP);
frame.getContentPane().add(consolesTab, BorderLayout.CENTER); frame.getContentPane().add(consolesTab, BorderLayout.CENTER);
serverConsoles = this; serverConsoles = this;
frame.setVisible(true);
} }
public static ServerConsoles getGUI() { public static ServerConsoles getGUI() {
@ -39,8 +37,8 @@ public class ServerConsoles {
frame.setVisible(true); frame.setVisible(true);
} }
public void addTab(String name) { public Console addTab(String name) {
new Console(consolesTab, name); return new Console(consolesTab, name);
} }
} }

View File

@ -58,7 +58,6 @@ public class ServerTab implements ActionListener {
JLabel lblMaxRam = new JLabel("Max ram"); JLabel lblMaxRam = new JLabel("Max ram");
sl_panel_3.putConstraint(SpringLayout.NORTH, lblMaxRam, 0, SpringLayout.NORTH, serverTypes); sl_panel_3.putConstraint(SpringLayout.NORTH, lblMaxRam, 0, SpringLayout.NORTH, serverTypes);
sl_panel_3.putConstraint(SpringLayout.SOUTH, lblMaxRam, 0, SpringLayout.SOUTH, serverTypes); sl_panel_3.putConstraint(SpringLayout.SOUTH, lblMaxRam, 0, SpringLayout.SOUTH, serverTypes);
sl_panel_3.putConstraint(SpringLayout.EAST, lblMaxRam, 50, SpringLayout.WEST, lblMaxRam);
sl_panel_3.putConstraint(SpringLayout.WEST, lblMaxRam, 6, SpringLayout.EAST, serverTypes); sl_panel_3.putConstraint(SpringLayout.WEST, lblMaxRam, 6, SpringLayout.EAST, serverTypes);
panel.add(lblMaxRam); panel.add(lblMaxRam);

View File

@ -2,6 +2,7 @@ import javax.naming.ConfigurationException;
import net.knarcraft.serverlauncher.server.*; import net.knarcraft.serverlauncher.server.*;
import net.knarcraft.serverlauncher.userinterface.GUI; import net.knarcraft.serverlauncher.userinterface.GUI;
import net.knarcraft.serverlauncher.userinterface.ServerTab;
import java.awt.*; import java.awt.*;
import java.io.*; import java.io.*;
@ -22,7 +23,8 @@ class ServerTest {
window.getFrame().setVisible(true); window.getFrame().setVisible(true);
Server server1 = new Server("Server1", window);
Server server1 = new Server("Server1", window, new ServerTab("Server1"));
server1.toggle(); server1.toggle();
server1.setPath("C:\\Users\\Kristian\\Desktop\\Test"); server1.setPath("C:\\Users\\Kristian\\Desktop\\Test");
server1.setType(ServerType.getServerTypes().get(4)); server1.setType(ServerType.getServerTypes().get(4));