From 74f8e2339b135dfa1d3cf16dc0cd386e1ebbc6c9 Mon Sep 17 00:00:00 2001 From: Bill Kuker Date: Sun, 5 Dec 2010 15:30:00 +0000 Subject: [PATCH] Add About box --- .../motorsim/visual/workbench/About.java | 124 ++++++++++++++++++ .../visual/workbench/MotorWorkbench.java | 18 +++ .../motorsim/visual/workbench/license.txt | 33 +++++ 3 files changed, 175 insertions(+) create mode 100644 gui/com/billkuker/rocketry/motorsim/visual/workbench/About.java create mode 100644 gui/com/billkuker/rocketry/motorsim/visual/workbench/license.txt diff --git a/gui/com/billkuker/rocketry/motorsim/visual/workbench/About.java b/gui/com/billkuker/rocketry/motorsim/visual/workbench/About.java new file mode 100644 index 0000000..f3620ba --- /dev/null +++ b/gui/com/billkuker/rocketry/motorsim/visual/workbench/About.java @@ -0,0 +1,124 @@ +package com.billkuker.rocketry.motorsim.visual.workbench; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Desktop; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URI; +import java.net.URISyntaxException; + +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class About extends JDialog { + private static final long serialVersionUID = 1L; + private final JFrame f; + + private final static URI webpage; + static { + try { + webpage = new URI( + "http://content.billkuker.com/projects/rocketry/software"); + } catch (URISyntaxException e) { + throw new Error(e); + } + } + + public About(final JFrame f) { + super(f, "About " + MotorWorkbench.name, true); + this.f = f; + setSize(400, 250); + + setIconImage(f.getIconImage()); + + setLayout(new BorderLayout()); + add(new JLabel("" + MotorWorkbench.name + + " ©2010 Bill Kuker"), BorderLayout.NORTH); + JTextArea text; + add(new JScrollPane(text = new JTextArea()), BorderLayout.CENTER); + text.setEditable(false); + StringBuffer lic = new StringBuffer(); + BufferedReader in = new BufferedReader(new InputStreamReader(getClass() + .getResourceAsStream("license.txt"))); + String line; + try { + while ((line = in.readLine()) != null) { + lic.append(line); + lic.append("\n"); + } + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + text.setText(lic.toString()); + JLabel link = new JLabel( + "Visit MotorSim on the Web"); + link.setForeground(Color.BLUE); + add(link, BorderLayout.SOUTH); + link.addMouseListener(new MouseListener() { + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseClicked(MouseEvent e) { + if (Desktop.isDesktopSupported()) { + Desktop desktop = Desktop.getDesktop(); + try { + desktop.browse(webpage); + } catch (IOException x) { + + } + } else { + + } + + } + }); + } + + @Override + public void setVisible(boolean v) { + int x = f.getLocation().x + f.getWidth() / 2 - getWidth() / 2; + int y = f.getLocation().y + f.getHeight() / 2 - getHeight() / 2; + setLocation(x, y); + super.setVisible(v); + } + + public static void main(String args[]) { + JFrame f = new JFrame(); + f.setSize(1024, 768); + f.setVisible(true); + final About s = new About(f); + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + s.setVisible(true); + + } + }); + + } +} diff --git a/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorWorkbench.java b/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorWorkbench.java index db8995d..313a1e5 100644 --- a/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorWorkbench.java +++ b/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorWorkbench.java @@ -31,6 +31,8 @@ public class MotorWorkbench extends RememberJFrame { private SettingsEditor settings = new SettingsEditor(this); + private About about = new About(this); + private JFrame fuelEditorFrame = new RememberJFrame(800,600){ private static final long serialVersionUID = 1L; { @@ -213,6 +215,22 @@ public class MotorWorkbench extends RememberJFrame { }); } }); + add(new JMenu("Help"){ + private static final long serialVersionUID = 1L; + { + add(new JMenuItem("About") { + private static final long serialVersionUID = 1L; + { + addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + about.setVisible(true); + } + }); + } + }); + } + }); } }); } diff --git a/gui/com/billkuker/rocketry/motorsim/visual/workbench/license.txt b/gui/com/billkuker/rocketry/motorsim/visual/workbench/license.txt new file mode 100644 index 0000000..e0cc42e --- /dev/null +++ b/gui/com/billkuker/rocketry/motorsim/visual/workbench/license.txt @@ -0,0 +1,33 @@ +THIS SOFTWARE IS INTENDED ONLY FOR THE +SIMULATION OF SOLID ROCKET MOTORS AS A +SUBSTITUTE FOR THE CONSTRUCTION AND +TESTING OF SOLID ROCKET MOTORS. THIS +SOFTWARE IS NEITHER INTENDED NOR LICENSED +AS AN AID IN EITHER THE DESIGN OR +CONSTRUCTION OF SOLID ROCKET MOTORS. + +You acknowledge that this software is not +designed, licensed or intended for use in +the design, construction, operation or +maintenance of any rocket motor or motor +component. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF +THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file -- 2.47.2