From 574c5622994f8ccc6469703050ca006d304d0018 Mon Sep 17 00:00:00 2001 From: Deathsbreed Date: Wed, 28 May 2014 09:38:05 -0500 Subject: [PATCH] There is now a Window that opens to display information, and various new menu items. There is also a shortcut to quit the application. --- src/spaceshipsim/SpaceShipSim.java | 26 +++++++++++++++++++++++--- src/spaceshipsim/Window.java | 5 +++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/spaceshipsim/SpaceShipSim.java b/src/spaceshipsim/SpaceShipSim.java index bb1b288..d5d3e7c 100644 --- a/src/spaceshipsim/SpaceShipSim.java +++ b/src/spaceshipsim/SpaceShipSim.java @@ -62,22 +62,42 @@ public class SpaceShipSim { instructionsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { - // Stuff happens. + new Window("Instructions", "Accelerate: Up Arrow\n" + + "Turn left: Left Arrow\n" + + "Turn right: Right Arrow\n\n"); } }); licenseItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { - // Stuff happens. + new Window("License Information", + "SpaceShipSim v0.2, a simulation of a spaceship in a frictionless environment\n" + + "Copyright (C) 2014 Nicolás A. Ortega\n\n" + + "This program is free software: you can redistribute it and/or modify\n" + + "it under the terms of the GNU General Public License as published by\n" + + "the Free Software Foundation, either version 3 of the License, or\n" + + "(at your option) any later version.\n\n" + + "This program is distributed in the hope that it will be useful,\n" + + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + + "GNU General Public License for more details.\n\n" + + "You should have received a copy of the GNU General Public License\n" + + "along with this program. If not, see .\n\n"); } }); aboutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { - // Stuff happens. + new Window("About", "SpaceShipSim v0.2\n" + + "Copyright (C) 2014 Nicolás A. Ortega\n" + + "Contact: nicolas.ortega.froysa@gmail.com\n" + + "Source-code: https://github.com/Deathsbreed/SpaceShipSim\n" + + "Developers: Nicolás Ortega\n\n"); } }); + exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_MASK)); + simulationMenu.add(resetItem); simulationMenu.addSeparator(); diff --git a/src/spaceshipsim/Window.java b/src/spaceshipsim/Window.java index e0f8ed9..faff1bb 100644 --- a/src/spaceshipsim/Window.java +++ b/src/spaceshipsim/Window.java @@ -1,7 +1,6 @@ package spaceshipsim; import javax.swing.*; -import java.awt.*; /** * @author Nicolás A. Ortega @@ -11,5 +10,7 @@ import java.awt.*; * */ public class Window { - // Stuff here. + public Window(String title, String infoMessage) { + JOptionPane.showMessageDialog(null, infoMessage, title, JOptionPane.INFORMATION_MESSAGE); + } } \ No newline at end of file