1 package net.sourceforge.simplegamenet.framework.gui;
2
3 import java.awt.*;
4 import java.awt.event.ActionEvent;
5 import java.awt.event.ActionListener;
6 import javax.swing.*;
7 import net.sourceforge.simplegamenet.framework.model.SimpleGameNetSettings;
8 import net.sourceforge.simplegamenet.util.proportionlayout.ProportionConstraints;
9 import net.sourceforge.simplegamenet.util.proportionlayout.ProportionLayout;
10
11 public class AboutDialog extends JDialog implements ActionListener {
12
13 private JButton okButton = new JButton("Ok");
14
15 public AboutDialog(SimpleGameNetFrame simpleGameNetFrame) {
16 super(simpleGameNetFrame, "About", true);
17 String[] authors = SimpleGameNetSettings.getInstance().getAuthors();
18 Container contentPanel = getContentPane();
19 ProportionLayout layout = new ProportionLayout();
20 layout.appendColumn(10);
21 layout.appendColumn(0, ProportionLayout.NO_PROPORTION);
22 layout.appendColumn(10);
23 layout.appendColumn(0, 1.0);
24 layout.appendColumn(10);
25 layout.appendRow(10);
26 layout.appendRow(0, 1.0);
27 layout.appendRow(10);
28 layout.appendRow(0, ProportionLayout.NO_PROPORTION);
29 layout.appendRow(10);
30 for (int i = 0; i < authors.length; i++) {
31 layout.appendRow(0, ProportionLayout.NO_PROPORTION);
32 layout.appendRow(10);
33 }
34 layout.appendRow(0, ProportionLayout.NO_PROPORTION);
35 layout.appendRow(10);
36 layout.appendRow(0, ProportionLayout.NO_PROPORTION);
37 layout.appendRow(10);
38 layout.appendRow(0, ProportionLayout.NO_PROPORTION);
39 layout.appendRow(10);
40 contentPanel.setLayout(layout);
41 ImageIcon simpleGameNetLogo = new ImageIcon(
42 getClass().getResource("SimpleGameNetLogo.png"),
43 "SimpleGameNet logo");
44 JLabel iconLabel = new JLabel(simpleGameNetLogo);
45 contentPanel.add(iconLabel, new ProportionConstraints(1, 1, 3, 1));
46 JLabel versionLabel = new JLabel("Version:");
47 contentPanel.add(versionLabel, new ProportionConstraints(1, 3));
48 JTextField versionField = new JTextField(
49 SimpleGameNetSettings.getInstance().getVersion().toString());
50 versionField.setEditable(false);
51 contentPanel.add(versionField, new ProportionConstraints(3, 3));
52 JLabel authorLabel = new JLabel("Authors:");
53 contentPanel.add(authorLabel, new ProportionConstraints(1, 5));
54 JTextField[] authorFields = new JTextField[authors.length];
55 for (int i = 0; i < authors.length; i++) {
56 authorFields[i] = new JTextField(authors[i]);
57 authorFields[i].setEditable(false);
58 contentPanel.add(authorFields[i],
59 new ProportionConstraints(3, 5 + (i * 2)));
60 }
61 JLabel siteLabel = new JLabel("Site:");
62 contentPanel.add(siteLabel, new ProportionConstraints(1, 5 + (authors.length * 2)));
63 JTextField siteField = new JTextField(
64 SimpleGameNetSettings.getInstance().getSite().toString());
65 siteField.setEditable(false);
66 contentPanel.add(siteField, new ProportionConstraints(3, 5 + (authors.length * 2)));
67 JLabel copyRightLabel = new JLabel("2003-2004 The 3 Belgians. All rights reserved.",
68 SwingConstants.CENTER);
69 copyRightLabel.setFont(new Font(copyRightLabel.getFont().getName(),
70 copyRightLabel.getFont().getStyle(), 10));
71 contentPanel.add(copyRightLabel,
72 new ProportionConstraints(1, 7 + (authors.length * 2), 3, 1));
73 okButton.addActionListener(this);
74 contentPanel.add(okButton, new ProportionConstraints(1, 9 + (authors.length * 2),
75 3, 1, 3, 9 + (authors.length * 2),
76 ProportionConstraints.CENTER,
77 ProportionConstraints.VERTICAL));
78 setResizable(false);
79 pack();
80 setLocationRelativeTo(simpleGameNetFrame);
81 }
82
83 public void actionPerformed(ActionEvent actionEvent) {
84 dispose();
85 }
86
87 }