1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.aequo.gui;
14
15 import java.awt.BorderLayout;
16 import java.awt.Color;
17 import java.awt.Component;
18 import java.awt.Cursor;
19 import java.awt.Dimension;
20 import java.awt.Graphics;
21 import java.awt.Toolkit;
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.util.Properties;
25
26 import javax.swing.Box;
27 import javax.swing.BoxLayout;
28 import javax.swing.Icon;
29 import javax.swing.ImageIcon;
30 import javax.swing.JComponent;
31 import javax.swing.JDialog;
32 import javax.swing.JFrame;
33 import javax.swing.JLabel;
34 import javax.swing.border.EmptyBorder;
35 import javax.swing.border.LineBorder;
36
37
38
39
40
41
42
43 public class AboutWindow extends JDialog {
44
45
46
47
48 public AboutWindow() {
49
50 Properties appInfo = new Properties();
51 try {
52 InputStream is = getClass().getResourceAsStream("/META-INF/appinfo.properties");
53 try {
54 appInfo.load(is);
55 } finally {
56 is.close();
57 }
58 } catch (IOException e) {
59 e.printStackTrace();
60 }
61
62 setModal(true);
63 setAlwaysOnTop(true);
64
65 GradientPanel panel = new GradientPanel(new BorderLayout());
66
67 setContentPane(panel);
68
69
70 Box ahPanel = new Box(BoxLayout.X_AXIS);
71 ahPanel.setOpaque(false);
72 LinePanel line1 = new LinePanel();
73 ahPanel.add(line1);
74 Icon ahIcon = new ImageIcon(getClass().getResource("/ah-logo-256-t.png"));
75 JLabel ahLabel = new JLabel(ahIcon);
76 ahLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
77 ahLabel.addMouseListener(new URLLink("http://www.abstracthorizon.org", this));
78 ahLabel.setMaximumSize(ahLabel.getPreferredSize());
79 ahPanel.add(ahLabel);
80 LinePanel line2 = new LinePanel();
81 ahPanel.add(line2);
82
83 panel.add(ahPanel, BorderLayout.NORTH);
84
85 Box center = new Box(BoxLayout.Y_AXIS);
86 center.setOpaque(false);
87 center.setBorder(new EmptyBorder(25, 50, 25, 50));
88 panel.add(center, BorderLayout.CENTER);
89
90 Icon aequoIcon = new ImageIcon(getClass().getResource("/aequo-logo-256.png"));
91 JLabel aequoLabel = new JLabel(aequoIcon, JLabel.CENTER);
92 aequoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
93 aequoLabel.addMouseListener(new URLLink("http://aequo.abstracthorizon.org", this));
94 aequoLabel.setBorder(new EmptyBorder(0, 0, 0, 0));
95 aequoLabel.setOpaque(false);
96 aequoLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
97 center.add(aequoLabel);
98
99
100
101
102
103
104 JLabel version = new JLabel("Version " + appInfo.getProperty("app.version"));
105 version.setFont(version.getFont().deriveFont(9.0f));
106 version.setOpaque(false);
107 version.setAlignmentX(Component.CENTER_ALIGNMENT);
108 version.setBorder(new EmptyBorder(10, 1, 1, 1));
109 center.add(version);
110
111
112 JLabel copyright = new JLabel(" (c) 2007 Abstract Horizon ", JLabel.CENTER);
113 copyright.setFont(copyright.getFont().deriveFont(9.0f));
114 copyright.setOpaque(false);
115 copyright.setBorder(new EmptyBorder(10, 1, 1, 1));
116 panel.add(copyright, BorderLayout.SOUTH);
117
118 panel.setBorder(new LineBorder(Color.DARK_GRAY, 1));
119
120 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
121 Dimension windowSize = getPreferredSize();
122
123 setBounds((screenSize.width - windowSize.width) / 2, (screenSize.height - windowSize.height) / 2, windowSize.width, windowSize.height);
124
125
126
127
128
129
130
131
132
133
134
135
136 pack();
137 }
138
139
140
141
142 public static class LinePanel extends JComponent {
143
144 public LinePanel() {
145 setOpaque(false);
146 }
147
148 public void paint(Graphics g) {
149 g.setColor(new Color(255, 127, 0));
150 int w = getWidth();
151 g.drawLine(0, 18, w, 18);
152 g.drawLine(0, 19, w, 19);
153 }
154
155 }
156
157 public static void main(String[] args) throws Exception {
158 AboutWindow w = new AboutWindow();
159 w.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
160 w.setVisible(true);
161 }
162 }