summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/gui/AboutDialog.java
diff options
context:
space:
mode:
authorGravatar jeff2014-07-29 00:37:51 -0400
committerGravatar jeff2014-07-29 00:37:51 -0400
commit1318888e5b37a2d76270c5c330e63d4b5dcf779e (patch)
tree1a26f087424b310fa8c7bf06fcccfb1f92d5bdca /src/cuchaz/enigma/gui/AboutDialog.java
parentadded identifier renaming capability (diff)
downloadenigma-fork-1318888e5b37a2d76270c5c330e63d4b5dcf779e.tar.gz
enigma-fork-1318888e5b37a2d76270c5c330e63d4b5dcf779e.tar.xz
enigma-fork-1318888e5b37a2d76270c5c330e63d4b5dcf779e.zip
added start of menu bar
added about bow
Diffstat (limited to '')
-rw-r--r--src/cuchaz/enigma/gui/AboutDialog.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/gui/AboutDialog.java b/src/cuchaz/enigma/gui/AboutDialog.java
new file mode 100644
index 0000000..2584182
--- /dev/null
+++ b/src/cuchaz/enigma/gui/AboutDialog.java
@@ -0,0 +1,86 @@
1package cuchaz.enigma.gui;
2
3import java.awt.Color;
4import java.awt.Container;
5import java.awt.Cursor;
6import java.awt.FlowLayout;
7import java.awt.event.ActionEvent;
8import java.awt.event.ActionListener;
9import java.io.IOException;
10
11import javax.swing.Box;
12import javax.swing.BoxLayout;
13import javax.swing.JButton;
14import javax.swing.JFrame;
15import javax.swing.JLabel;
16import javax.swing.JPanel;
17import javax.swing.WindowConstants;
18
19import cuchaz.enigma.Constants;
20import cuchaz.enigma.Util;
21
22public class AboutDialog
23{
24 public static void show( JFrame parent )
25 {
26 // init frame
27 final JFrame frame = new JFrame( Constants.Name + " - About" );
28 final Container pane = frame.getContentPane();
29 pane.setLayout( new FlowLayout() );
30
31 // load the content
32 try
33 {
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 }
40 catch( IOException ex )
41 {
42 throw new Error( ex );
43 }
44
45 // show the link
46 String html = "<html><a href=\"%s\">%s</a></html>";
47 html = String.format( html, Constants.Url, Constants.Url );
48 JButton link = new JButton( html );
49 link.addActionListener( new ActionListener( )
50 {
51 @Override
52 public void actionPerformed( ActionEvent event )
53 {
54 Util.openUrl( Constants.Url );
55 }
56 } );
57 link.setBorderPainted( false );
58 link.setOpaque( false );
59 link.setBackground( Color.WHITE );
60 link.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
61 link.setFocusable( false );
62 JPanel linkPanel = new JPanel();
63 linkPanel.add( link );
64 pane.add( linkPanel );
65
66 // show ok button
67 JButton okButton = new JButton( "Ok" );
68 pane.add( okButton );
69 okButton.addActionListener( new ActionListener( )
70 {
71 @Override
72 public void actionPerformed( ActionEvent arg0 )
73 {
74 frame.dispose();
75 }
76 } );
77
78 // show the frame
79 pane.doLayout();
80 frame.setSize( 400, 220 );
81 frame.setResizable( false );
82 frame.setLocationRelativeTo( parent );
83 frame.setVisible( true );
84 frame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE );
85 }
86}