current main window
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 4 Apr 2008 22:08:12 +0000 (22:08 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 4 Apr 2008 22:08:12 +0000 (22:08 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@593 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/jsite/gui/MainWindow.java

index 3e8e965..0c46ad5 100644 (file)
 
 package net.pterodactylus.jsite.gui;
 
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+
 import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+
+import net.pterodactylus.jsite.i18n.I18n;
+import net.pterodactylus.jsite.main.Version;
+import net.pterodactylus.util.swing.StatusBar;
+import net.pterodactylus.util.swing.SwingUtils;
 
 /**
  * Defines the main window of the application.
@@ -29,4 +39,71 @@ import javax.swing.JFrame;
  */
 public class MainWindow extends JFrame {
 
+       /** The swing interface that receives all actions. */
+       private final SwingInterface swingInterface;
+
+       /** The status bar. */
+       private StatusBar statusBar = new StatusBar();
+
+       /**
+        * Creates a new main window that redirects all actions to the given swing
+        * interface.
+        * 
+        * @param swingInterface
+        *            The swing interface to receive all actions
+        */
+       public MainWindow(SwingInterface swingInterface) {
+               super("jSite " + Version.getVersion());
+               this.swingInterface = swingInterface;
+               initWindow();
+               setPreferredSize(new Dimension(480, 280));
+               pack();
+               SwingUtils.center(this);
+               setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+       }
+
+       //
+       // ACCESSORS
+       //
+
+       /**
+        * Sets the text of the status bar.
+        * 
+        * @param text
+        *            The text of the status bar
+        */
+       public void setStatusBarText(String text) {
+               statusBar.setText(text);
+       }
+
+       //
+       // PRIVATE METHODS
+       //
+
+       /**
+        * Initializes the window by creating all its components.
+        */
+       private void initWindow() {
+               JMenuBar menuBar = new JMenuBar();
+
+               final JMenu nodeMenu = new JMenu(I18n.get("mainWindow.menu.node.name"));
+               menuBar.add(nodeMenu);
+               nodeMenu.setMnemonic(I18n.get("mainWindow.menu.node.mnemonic").charAt(0));
+
+               nodeMenu.add(swingInterface.getManageNodesAction());
+               nodeMenu.addSeparator();
+               nodeMenu.add(swingInterface.getNodeConnectAction());
+               nodeMenu.add(swingInterface.getNodeDisconnectAction());
+
+               setJMenuBar(menuBar);
+               initComponents();
+       }
+
+       /**
+        * Initializes all components of this window.
+        */
+       private void initComponents() {
+               getContentPane().add(statusBar, BorderLayout.PAGE_END);
+       }
+
 }