109 lines
5.7 KiB
Java
109 lines
5.7 KiB
Java
|
package net.knarcraft.serverlauncher.userinterface;
|
||
|
|
||
|
import net.knarcraft.serverlauncher.server.Server;
|
||
|
import net.knarcraft.serverlauncher.server.ServerType;
|
||
|
|
||
|
import javax.swing.*;
|
||
|
import java.awt.event.ActionEvent;
|
||
|
import java.awt.event.ActionListener;
|
||
|
|
||
|
public class ServerTab implements ActionListener {
|
||
|
private JComboBox<String> serverTypes, serverVersions, maxRam;
|
||
|
private JCheckBox chckbxEnabled;
|
||
|
private JButton btnRemoveServer, btnBrowse;
|
||
|
private JTextField directory;
|
||
|
|
||
|
|
||
|
public ServerTab(String name) {
|
||
|
JPanel panel = new JPanel();
|
||
|
Server.getGUI().getPane().addTab(name, null, panel, null);
|
||
|
SpringLayout sl_panel_3 = new SpringLayout();
|
||
|
panel.setLayout(sl_panel_3);
|
||
|
|
||
|
JLabel lblServerType = new JLabel("Server type");
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, lblServerType, 10, SpringLayout.NORTH, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.WEST, lblServerType, 10, SpringLayout.WEST, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.SOUTH, lblServerType, 30, SpringLayout.NORTH, panel);
|
||
|
panel.add(lblServerType);
|
||
|
|
||
|
serverTypes = new JComboBox<>(ServerType.getTypeNames());
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, serverTypes, 10, SpringLayout.NORTH, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.WEST, serverTypes, 16, SpringLayout.EAST, lblServerType);
|
||
|
panel.add(serverTypes);
|
||
|
serverTypes.addActionListener(this);
|
||
|
|
||
|
JLabel lblServerVersion = new JLabel("Server version");
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, lblServerVersion, 6, SpringLayout.SOUTH, lblServerType);
|
||
|
sl_panel_3.putConstraint(SpringLayout.WEST, lblServerVersion, 10, SpringLayout.WEST, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.SOUTH, lblServerVersion, 26, SpringLayout.SOUTH, lblServerType);
|
||
|
panel.add(lblServerVersion);
|
||
|
|
||
|
serverVersions = new JComboBox<>(ServerType.getServerTypes().get(0).getVersions());
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, serverVersions, 6, SpringLayout.SOUTH, serverTypes);
|
||
|
sl_panel_3.putConstraint(SpringLayout.WEST, serverVersions, 0, SpringLayout.WEST, serverTypes);
|
||
|
panel.add(serverVersions);
|
||
|
serverVersions.addActionListener(this);
|
||
|
|
||
|
JLabel lblMaxRam = new JLabel("Max ram");
|
||
|
sl_panel_3.putConstraint(SpringLayout.EAST, serverTypes, -13, SpringLayout.WEST, lblMaxRam);
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, lblMaxRam, 10, SpringLayout.NORTH, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.SOUTH, lblMaxRam, -92, SpringLayout.SOUTH, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.EAST, lblMaxRam, -111, SpringLayout.EAST, panel);
|
||
|
panel.add(lblMaxRam);
|
||
|
|
||
|
maxRam = new JComboBox<>(Server.getRamList());
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, maxRam, 10, SpringLayout.NORTH, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.WEST, maxRam, 6, SpringLayout.EAST, lblMaxRam);
|
||
|
sl_panel_3.putConstraint(SpringLayout.EAST, maxRam, 86, SpringLayout.EAST, lblMaxRam);
|
||
|
panel.add(maxRam);
|
||
|
maxRam.addActionListener(this);
|
||
|
|
||
|
chckbxEnabled = new JCheckBox("Enabled");
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, chckbxEnabled, 6, SpringLayout.SOUTH, lblServerVersion);
|
||
|
sl_panel_3.putConstraint(SpringLayout.EAST, chckbxEnabled, 0, SpringLayout.EAST, lblServerType);
|
||
|
panel.add(chckbxEnabled);
|
||
|
chckbxEnabled.addActionListener(this);
|
||
|
|
||
|
btnRemoveServer = new JButton("Remove server");
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, btnRemoveServer, 5, SpringLayout.SOUTH, lblMaxRam);
|
||
|
sl_panel_3.putConstraint(SpringLayout.SOUTH, btnRemoveServer, -64, SpringLayout.SOUTH, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.SOUTH, maxRam, -5, SpringLayout.NORTH, btnRemoveServer);
|
||
|
sl_panel_3.putConstraint(SpringLayout.EAST, serverVersions, -13, SpringLayout.WEST, btnRemoveServer);
|
||
|
sl_panel_3.putConstraint(SpringLayout.WEST, btnRemoveServer, 239, SpringLayout.WEST, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.EAST, btnRemoveServer, 0, SpringLayout.EAST, maxRam);
|
||
|
panel.add(btnRemoveServer);
|
||
|
btnRemoveServer.addActionListener(this);
|
||
|
|
||
|
JLabel lblDirectory = new JLabel("Directory");
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, lblDirectory, 1, SpringLayout.NORTH, chckbxEnabled);
|
||
|
sl_panel_3.putConstraint(SpringLayout.SOUTH, lblDirectory, 0, SpringLayout.SOUTH, chckbxEnabled);
|
||
|
panel.add(lblDirectory);
|
||
|
|
||
|
directory = new JTextField();
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, directory, 4, SpringLayout.SOUTH, btnRemoveServer);
|
||
|
sl_panel_3.putConstraint(SpringLayout.SOUTH, directory, -37, SpringLayout.SOUTH, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.EAST, lblDirectory, -6, SpringLayout.WEST, directory);
|
||
|
sl_panel_3.putConstraint(SpringLayout.WEST, directory, 130, SpringLayout.WEST, panel);
|
||
|
panel.add(directory);
|
||
|
directory.setColumns(10);
|
||
|
directory.addActionListener(this);
|
||
|
|
||
|
btnBrowse = new JButton("Browse");
|
||
|
sl_panel_3.putConstraint(SpringLayout.EAST, directory, -6, SpringLayout.WEST, btnBrowse);
|
||
|
sl_panel_3.putConstraint(SpringLayout.NORTH, btnBrowse, 3, SpringLayout.SOUTH, btnRemoveServer);
|
||
|
sl_panel_3.putConstraint(SpringLayout.WEST, btnBrowse, 293, SpringLayout.WEST, panel);
|
||
|
sl_panel_3.putConstraint(SpringLayout.EAST, btnBrowse, 0, SpringLayout.EAST, maxRam);
|
||
|
panel.add(btnBrowse);
|
||
|
btnBrowse.addActionListener(this);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void actionPerformed(ActionEvent e) {
|
||
|
if (e.getSource() == btnRemoveServer) {
|
||
|
Server.getGUI().removeServer(this);
|
||
|
} else if (e.getSource() == btnBrowse) {
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|