summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/gui/AboutDialog.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/gui/AboutDialog.java')
-rw-r--r--src/cuchaz/enigma/gui/AboutDialog.java80
1 files changed, 36 insertions, 44 deletions
diff --git a/src/cuchaz/enigma/gui/AboutDialog.java b/src/cuchaz/enigma/gui/AboutDialog.java
index a245956..2476b56 100644
--- a/src/cuchaz/enigma/gui/AboutDialog.java
+++ b/src/cuchaz/enigma/gui/AboutDialog.java
@@ -27,68 +27,60 @@ import javax.swing.WindowConstants;
27import cuchaz.enigma.Constants; 27import cuchaz.enigma.Constants;
28import cuchaz.enigma.Util; 28import cuchaz.enigma.Util;
29 29
30public class AboutDialog 30public class AboutDialog {
31{ 31
32 public static void show( JFrame parent ) 32 public static void show(JFrame parent) {
33 {
34 // init frame 33 // init frame
35 final JFrame frame = new JFrame( Constants.Name + " - About" ); 34 final JFrame frame = new JFrame(Constants.Name + " - About");
36 final Container pane = frame.getContentPane(); 35 final Container pane = frame.getContentPane();
37 pane.setLayout( new FlowLayout() ); 36 pane.setLayout(new FlowLayout());
38 37
39 // load the content 38 // load the content
40 try 39 try {
41 { 40 String html = Util.readResourceToString("/about.html");
42 String html = Util.readResourceToString( "/about.html" ); 41 html = String.format(html, Constants.Name, Constants.Version);
43 html = String.format( html, Constants.Name, Constants.Version ); 42 JLabel label = new JLabel(html);
44 JLabel label = new JLabel( html ); 43 label.setHorizontalAlignment(JLabel.CENTER);
45 label.setHorizontalAlignment( JLabel.CENTER ); 44 pane.add(label);
46 pane.add( label ); 45 } catch (IOException ex) {
47 } 46 throw new Error(ex);
48 catch( IOException ex )
49 {
50 throw new Error( ex );
51 } 47 }
52 48
53 // show the link 49 // show the link
54 String html = "<html><a href=\"%s\">%s</a></html>"; 50 String html = "<html><a href=\"%s\">%s</a></html>";
55 html = String.format( html, Constants.Url, Constants.Url ); 51 html = String.format(html, Constants.Url, Constants.Url);
56 JButton link = new JButton( html ); 52 JButton link = new JButton(html);
57 link.addActionListener( new ActionListener( ) 53 link.addActionListener(new ActionListener() {
58 {
59 @Override 54 @Override
60 public void actionPerformed( ActionEvent event ) 55 public void actionPerformed(ActionEvent event) {
61 { 56 Util.openUrl(Constants.Url);
62 Util.openUrl( Constants.Url );
63 } 57 }
64 } ); 58 });
65 link.setBorderPainted( false ); 59 link.setBorderPainted(false);
66 link.setOpaque( false ); 60 link.setOpaque(false);
67 link.setBackground( Color.WHITE ); 61 link.setBackground(Color.WHITE);
68 link.setCursor( new Cursor( Cursor.HAND_CURSOR ) ); 62 link.setCursor(new Cursor(Cursor.HAND_CURSOR));
69 link.setFocusable( false ); 63 link.setFocusable(false);
70 JPanel linkPanel = new JPanel(); 64 JPanel linkPanel = new JPanel();
71 linkPanel.add( link ); 65 linkPanel.add(link);
72 pane.add( linkPanel ); 66 pane.add(linkPanel);
73 67
74 // show ok button 68 // show ok button
75 JButton okButton = new JButton( "Ok" ); 69 JButton okButton = new JButton("Ok");
76 pane.add( okButton ); 70 pane.add(okButton);
77 okButton.addActionListener( new ActionListener( ) 71 okButton.addActionListener(new ActionListener() {
78 {
79 @Override 72 @Override
80 public void actionPerformed( ActionEvent arg0 ) 73 public void actionPerformed(ActionEvent arg0) {
81 {
82 frame.dispose(); 74 frame.dispose();
83 } 75 }
84 } ); 76 });
85 77
86 // show the frame 78 // show the frame
87 pane.doLayout(); 79 pane.doLayout();
88 frame.setSize( 400, 220 ); 80 frame.setSize(400, 220);
89 frame.setResizable( false ); 81 frame.setResizable(false);
90 frame.setLocationRelativeTo( parent ); 82 frame.setLocationRelativeTo(parent);
91 frame.setVisible( true ); 83 frame.setVisible(true);
92 frame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE ); 84 frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
93 } 85 }
94} 86}