diff options
| author | 2016-07-03 00:05:04 +1000 | |
|---|---|---|
| committer | 2016-07-03 00:05:04 +1000 | |
| commit | 9a3e5a9d132735f818c379ba72c554362650690d (patch) | |
| tree | 2a454f96d99bdcfc5bdf0f6814a2ea7857698d1b /src/main/java/cuchaz/enigma/gui/AboutDialog.java | |
| parent | Fixed #4 (diff) | |
| download | enigma-fork-9a3e5a9d132735f818c379ba72c554362650690d.tar.gz enigma-fork-9a3e5a9d132735f818c379ba72c554362650690d.tar.xz enigma-fork-9a3e5a9d132735f818c379ba72c554362650690d.zip | |
Started Gui Refactor
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/AboutDialog.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/AboutDialog.java | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/AboutDialog.java b/src/main/java/cuchaz/enigma/gui/AboutDialog.java deleted file mode 100644 index bb12466..0000000 --- a/src/main/java/cuchaz/enigma/gui/AboutDialog.java +++ /dev/null | |||
| @@ -1,70 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.gui; | ||
| 12 | |||
| 13 | import java.awt.Color; | ||
| 14 | import java.awt.Container; | ||
| 15 | import java.awt.Cursor; | ||
| 16 | import java.awt.FlowLayout; | ||
| 17 | import java.io.IOException; | ||
| 18 | |||
| 19 | import javax.swing.*; | ||
| 20 | |||
| 21 | import cuchaz.enigma.Constants; | ||
| 22 | import cuchaz.enigma.Util; | ||
| 23 | |||
| 24 | public class AboutDialog { | ||
| 25 | |||
| 26 | public static void show(JFrame parent) { | ||
| 27 | // init frame | ||
| 28 | final JFrame frame = new JFrame(Constants.NAME + " - About"); | ||
| 29 | final Container pane = frame.getContentPane(); | ||
| 30 | pane.setLayout(new FlowLayout()); | ||
| 31 | |||
| 32 | // load the content | ||
| 33 | try { | ||
| 34 | String html = Util.readResourceToString("/about.html"); | ||
| 35 | html = String.format(html, Constants.NAME, Constants.VERSION); | ||
| 36 | JLabel label = new JLabel(html); | ||
| 37 | label.setHorizontalAlignment(JLabel.CENTER); | ||
| 38 | pane.add(label); | ||
| 39 | } catch (IOException ex) { | ||
| 40 | throw new Error(ex); | ||
| 41 | } | ||
| 42 | |||
| 43 | // show the link | ||
| 44 | String html = "<html><a href=\"%s\">%s</a></html>"; | ||
| 45 | html = String.format(html, Constants.URL, Constants.URL); | ||
| 46 | JButton link = new JButton(html); | ||
| 47 | link.addActionListener(event -> Util.openUrl(Constants.URL)); | ||
| 48 | link.setBorderPainted(false); | ||
| 49 | link.setOpaque(false); | ||
| 50 | link.setBackground(Color.WHITE); | ||
| 51 | link.setCursor(new Cursor(Cursor.HAND_CURSOR)); | ||
| 52 | link.setFocusable(false); | ||
| 53 | JPanel linkPanel = new JPanel(); | ||
| 54 | linkPanel.add(link); | ||
| 55 | pane.add(linkPanel); | ||
| 56 | |||
| 57 | // show ok button | ||
| 58 | JButton okButton = new JButton("Ok"); | ||
| 59 | pane.add(okButton); | ||
| 60 | okButton.addActionListener(arg0 -> frame.dispose()); | ||
| 61 | |||
| 62 | // show the frame | ||
| 63 | pane.doLayout(); | ||
| 64 | frame.setSize(400, 220); | ||
| 65 | frame.setResizable(false); | ||
| 66 | frame.setLocationRelativeTo(parent); | ||
| 67 | frame.setVisible(true); | ||
| 68 | frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); | ||
| 69 | } | ||
| 70 | } | ||