Nicer but probably less cross-compatible GUI
This commit is contained in:
parent
4ff0564482
commit
1fafab78b6
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.serverlauncher.userinterface;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
@ -12,6 +13,18 @@ import java.awt.*;
|
||||
*/
|
||||
public class GUI {
|
||||
public GUI() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnsupportedLookAndFeelException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JFrame frame = new JFrame("Minecraft server launcher");
|
||||
ImageIcon img = new ImageIcon("files/GUIIcon.png");
|
||||
frame.setIconImage(img.getImage());
|
||||
@ -64,15 +77,49 @@ public class GUI {
|
||||
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");
|
||||
//First tab
|
||||
JPanel controlPanel = new JPanel();
|
||||
controlPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
GroupLayout controlLayout = new GroupLayout(controlPanel);
|
||||
controlPanel.setLayout(controlLayout);
|
||||
JLabel basicControls = customLabel("Basic controls");
|
||||
JButton sendStart = customButton("Start servers");
|
||||
JButton sendStop = customButton("Stop servers");
|
||||
JButton backup = customButton("Backup");
|
||||
JButton viewConsole = customButton("View server consoles");
|
||||
JLabel profile = customLabel("Profile");
|
||||
|
||||
controlLayout.setVerticalGroup(
|
||||
controlLayout.createSequentialGroup()
|
||||
.addGroup(controlLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(basicControls))
|
||||
.addGroup(controlLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(sendStart)
|
||||
.addComponent(sendStop)
|
||||
.addComponent(backup)
|
||||
.addComponent(viewConsole))
|
||||
.addGroup(controlLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(profile)));
|
||||
|
||||
controlLayout.setHorizontalGroup(
|
||||
controlLayout.createSequentialGroup()
|
||||
.addGroup(controlLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addComponent(basicControls)
|
||||
.addComponent(profile)
|
||||
.addComponent(sendStart))
|
||||
.addGroup(controlLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addComponent(sendStop))
|
||||
.addGroup(controlLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addComponent(backup))
|
||||
.addGroup(controlLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addComponent(viewConsole)));
|
||||
|
||||
|
||||
tabs.addTab("Control panel", null, controlPanel, "Basic server controls");
|
||||
|
||||
JPanel serversPanel = new JPanel();
|
||||
tabs.addTab("Control servers", null, serversPanel, "Easy server commands");
|
||||
|
||||
panel.add(basicControls);
|
||||
panel.add(sendStart);
|
||||
panel.add(sendStop);
|
||||
tabs.addTab("Basic controls", null, panel, "Basic server controls");
|
||||
frame.add(tabs);
|
||||
|
||||
// TODO: Finish gui
|
||||
@ -84,4 +131,15 @@ public class GUI {
|
||||
Insets insets = frame.getInsets();
|
||||
frame.setSize(450 + 2 * insets.left, 170 + insets.top + insets.bottom);
|
||||
}
|
||||
|
||||
private JButton customButton(String text) {
|
||||
JButton button = new JButton(text);
|
||||
button.setMargin(new Insets(3,5,3,5));
|
||||
return button;
|
||||
}
|
||||
private JLabel customLabel(String text) {
|
||||
JLabel label = new JLabel(text);
|
||||
label.setBorder(new EmptyBorder(1, 2, 1, 0));
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user