X-Git-Url: https://git.pterodactylus.net/?p=jkeytool.git;a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjkeytool%2Fgui%2Fswing%2FSwingInterface.java;h=7e3e300b65f831dd6a76c7ccb55cdba29ccc2cd2;hp=b67ce8489703d32c937b7a958c3bd7e1cf8e8a17;hb=56eee1c83b115795d71515ee5b65d5ef6b05c22f;hpb=7430f3956390c9784094984eb7de2a1eee833aae diff --git a/src/net/pterodactylus/jkeytool/gui/swing/SwingInterface.java b/src/net/pterodactylus/jkeytool/gui/swing/SwingInterface.java index b67ce84..7e3e300 100644 --- a/src/net/pterodactylus/jkeytool/gui/swing/SwingInterface.java +++ b/src/net/pterodactylus/jkeytool/gui/swing/SwingInterface.java @@ -21,6 +21,8 @@ package net.pterodactylus.jkeytool.gui.swing; import java.awt.BorderLayout; import java.awt.event.ActionEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.io.File; import java.security.KeyStore; import java.util.HashMap; @@ -75,6 +77,9 @@ public class SwingInterface implements Interface { /** Loaded key stores and their panels. */ private final Map keyStores = new HashMap(); + /** + * Creates a new Swing interface. + */ public SwingInterface() { createActions(); createFrame(); @@ -84,9 +89,16 @@ public class SwingInterface implements Interface { // ACTIONS // + /** + * Creates a new key store. + */ private void createKeyStore() { + /* TODO */ } + /** + * Exits the application. + */ private void quit() { System.exit(0); } @@ -95,6 +107,9 @@ public class SwingInterface implements Interface { // PRIVATE METHODS // + /** + * Creates all used actions. + */ private void createActions() { createKeyStoreAction = new I18nAction(i18n, "jkeytool.action.createKeyStore") { @@ -115,14 +130,33 @@ public class SwingInterface implements Interface { }; } + /** + * Creates the application main frame. + */ private void createFrame() { mainFrame.setJMenuBar(createMenubar()); mainFrame.getContentPane().add(createToolbar(), BorderLayout.PAGE_START); mainFrame.getContentPane().add(createCenterPanel(), BorderLayout.CENTER); mainFrame.getContentPane().add(statusBar, BorderLayout.PAGE_END); mainFrame.pack(); + mainFrame.addWindowListener(new WindowAdapter() { + + /** + * {@inheritDoc} + */ + @Override + @SuppressWarnings("synthetic-access") + public void windowClosing(WindowEvent windowEvent) { + quit(); + } + }); } + /** + * Creates the central panel of the frame. + * + * @return The central panel of the frame + */ private JComponent createCenterPanel() { JPanel centerPanel = new JPanel(new BorderLayout()); centerPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); @@ -132,6 +166,11 @@ public class SwingInterface implements Interface { return centerPanel; } + /** + * Creates the menu bar of the frame. + * + * @return The menu bar of the frame + */ private JMenuBar createMenubar() { JMenuBar menubar = new JMenuBar(); @@ -144,6 +183,11 @@ public class SwingInterface implements Interface { return menubar; } + /** + * Creates the tool bar of the frame. + * + * @return The tool bar of the frame + */ private JToolBar createToolbar() { JToolBar toolbar = new JToolBar(); @@ -198,7 +242,7 @@ public class SwingInterface implements Interface { * {@inheritDoc} */ public void keyStoreLoaded(File keyStoreFile, KeyStore keyStore) { - KeyStorePanel keyStorePanel = new KeyStorePanel(keyStore); + KeyStorePanel keyStorePanel = new KeyStorePanel(i18n, keyStore); keyStores.put(keyStore, keyStorePanel); tabPane.addTab(keyStoreFile.getName(), keyStorePanel); }