From a650cbe18868a3db627f2410ce7441c29ceed253 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 4 Apr 2008 22:08:12 +0000 Subject: [PATCH] current main window git-svn-id: http://trooper/svn/projects/jSite/trunk@593 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/jsite/gui/MainWindow.java | 77 +++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/net/pterodactylus/jsite/gui/MainWindow.java b/src/net/pterodactylus/jsite/gui/MainWindow.java index 3e8e965..0c46ad5 100644 --- a/src/net/pterodactylus/jsite/gui/MainWindow.java +++ b/src/net/pterodactylus/jsite/gui/MainWindow.java @@ -19,7 +19,17 @@ 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); + } + } -- 2.7.4