Add unfinished gui
This commit is contained in:
96
src/net/knarcraft/serverlauncher/userinterface/GUI.java
Normal file
96
src/net/knarcraft/serverlauncher/userinterface/GUI.java
Normal file
@ -0,0 +1,96 @@
|
||||
package net.knarcraft.serverlauncher.userinterface;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* A class for creating the gui.
|
||||
*
|
||||
* @author Kristian Knarvik <kristian.knarvik@knett.no>
|
||||
* @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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user