Added the title and icon again

This commit is contained in:
2018-01-30 17:14:29 +01:00
parent 559e7bb38a
commit 89f0962c2d
5 changed files with 77 additions and 15 deletions

View File

@ -3,6 +3,7 @@ package net.knarcraft.serverlauncher.userinterface;
import net.knarcraft.serverlauncher.server.Server;
import net.knarcraft.serverlauncher.profile.Profile;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -94,10 +95,6 @@ public class GUI implements ActionListener {
return gui;
}
public ArrayList<ServerTab> getServerTabs() {
return this.serverTabs;
}
/**
* Removes a server's tab, removes it from the list of tabs, and removes the server from Profile.java
*
@ -125,10 +122,17 @@ public class GUI implements ActionListener {
e.printStackTrace();
}
frame = new JFrame();
frame = new JFrame("Minecraft server launcher");
frame.setBounds(100, 100, 398, 219);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setResizable(false);
ImageIcon img;
try {
img = new ImageIcon(ImageIO.read(GUI.class.getResourceAsStream("/files/GUIIcon.png")));
} catch (IOException | IllegalArgumentException e) {
img = new ImageIcon("files/GUIIcon.png");
}
frame.setIconImage(img.getImage());
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
@ -394,7 +398,6 @@ public class GUI implements ActionListener {
if (selectedPlayer != null) {
selectedPlayerValue = selectedPlayer.toString();
}
if (e.getSource() == chckbxmntmRunInBackground) {
background();
} else if (e.getSource() == chckbxmntmDelayStartup) {
@ -418,7 +421,7 @@ public class GUI implements ActionListener {
} else if (e.getSource() == mntmStory) {
goToURL("https://knarcraft.net/Bungeeminecraftserverlauncher/Story/");
} else if (e.getSource() == btnStartServer) {
save();
this.save();
Server.startServers();
} else if (e.getSource() == btnStopServer) {
stop();
@ -427,7 +430,7 @@ public class GUI implements ActionListener {
if (!serverName.equals("") && !currentProfile().serverExists(serverName)) {
new Server(serverName, this);
} else {
JOptionPane.showMessageDialog(null, "A servername must my unique and not empty.", "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, "A server name must my unique and not empty.", "Error", JOptionPane.ERROR_MESSAGE);
}
} else if (e.getSource() == backup) {
backup();
@ -475,8 +478,7 @@ public class GUI implements ActionListener {
* Reads all combo boxes, updates variables and saves to disk
*/
private void save() {
//TODO: Finish save
currentProfile().save(serverTabs);
}
/**

View File

@ -7,7 +7,7 @@ import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
class ServerTab implements ActionListener {
public class ServerTab implements ActionListener {
private final JComboBox<String> serverTypes;
private final JComboBox<String> serverVersions;
private final JComboBox<String> maxRam;
@ -16,8 +16,6 @@ class ServerTab implements ActionListener {
private final JButton btnBrowse;
private final JTextField directory;
//TODO: Add custom input field + update combo boxes on version change.
public ServerTab(String name) {
JPanel panel = new JPanel();
GUI.getGUI().getPane().addTab(name, null, panel, null);
@ -101,6 +99,41 @@ class ServerTab implements ActionListener {
btnBrowse.addActionListener(this);
}
public String getPath() {
return this.directory.getText();
}
public String getMaxRam() {
Object selected = this.maxRam.getSelectedItem();
if (selected != null) {
return selected.toString();
} else {
return "512M";
}
}
public String getType() {
Object selected = this.serverTypes.getSelectedItem();
if (selected != null) {
return selected.toString();
} else {
return "Vanilla";
}
}
public String getVersion() {
Object selected = this.serverVersions.getSelectedItem();
if (selected != null) {
return selected.toString();
} else {
return "Vanilla";
}
}
public boolean enabled() {
return this.chckbxEnabled.isSelected();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnRemoveServer) {