1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
package info.bioinfweb.commons.swing; |
20 |
|
21 |
|
22 |
import java.awt.Component; |
23 |
import java.awt.Dialog; |
24 |
import java.awt.Frame; |
25 |
import java.awt.GraphicsConfiguration; |
26 |
import java.awt.GridBagConstraints; |
27 |
import java.awt.GridBagLayout; |
28 |
import java.awt.Insets; |
29 |
import java.awt.Window; |
30 |
|
31 |
import javax.swing.BoxLayout; |
32 |
import javax.swing.Icon; |
33 |
import javax.swing.JButton; |
34 |
import javax.swing.JDialog; |
35 |
import javax.swing.JEditorPane; |
36 |
import javax.swing.JPanel; |
37 |
import javax.swing.JScrollPane; |
38 |
import javax.swing.JTabbedPane; |
39 |
import javax.swing.event.HyperlinkListener; |
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
@link |
47 |
@link@link |
48 |
|
49 |
@author |
50 |
@since |
51 |
|
52 |
public class AboutDialog extends JDialog { |
53 |
private static final long serialVersionUID = 1L; |
54 |
|
55 |
private JPanel jContentPane = null; |
56 |
private JTabbedPane tabbedPane; |
57 |
private JPanel buttonPanel = null; |
58 |
private JButton closeButton = null; |
59 |
private HyperlinkListener hyperlinkListener = new SystemBrowserHyperlinkListener(this); |
60 |
|
61 |
|
62 |
public AboutDialog(Dialog owner, boolean modal) { |
63 |
super(owner, modal); |
64 |
init(); |
65 |
} |
66 |
|
67 |
|
68 |
public AboutDialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc) { |
69 |
super(owner, title, modal, gc); |
70 |
init(); |
71 |
} |
72 |
|
73 |
|
74 |
public AboutDialog(Dialog owner, String title, boolean modal) { |
75 |
super(owner, title, modal); |
76 |
init(); |
77 |
} |
78 |
|
79 |
|
80 |
public AboutDialog(Dialog owner, String title) { |
81 |
super(owner, title); |
82 |
init(); |
83 |
} |
84 |
|
85 |
|
86 |
public AboutDialog(Dialog owner) { |
87 |
super(owner); |
88 |
init(); |
89 |
} |
90 |
|
91 |
|
92 |
public AboutDialog(Frame owner, boolean modal) { |
93 |
super(owner, modal); |
94 |
init(); |
95 |
} |
96 |
|
97 |
|
98 |
public AboutDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) { |
99 |
super(owner, title, modal, gc); |
100 |
init(); |
101 |
} |
102 |
|
103 |
|
104 |
public AboutDialog(Frame owner, String title, boolean modal) { |
105 |
super(owner, title, modal); |
106 |
init(); |
107 |
} |
108 |
|
109 |
|
110 |
public AboutDialog(Frame owner, String title) { |
111 |
super(owner, title); |
112 |
init(); |
113 |
} |
114 |
|
115 |
|
116 |
public AboutDialog(Frame owner) { |
117 |
super(owner); |
118 |
init(); |
119 |
} |
120 |
|
121 |
|
122 |
public AboutDialog(Window owner, ModalityType modalityType) { |
123 |
super(owner, modalityType); |
124 |
init(); |
125 |
} |
126 |
|
127 |
|
128 |
public AboutDialog(Window owner, String title, ModalityType modalityType, GraphicsConfiguration gc) { |
129 |
super(owner, title, modalityType, gc); |
130 |
init(); |
131 |
} |
132 |
|
133 |
|
134 |
public AboutDialog(Window owner, String title, ModalityType modalityType) { |
135 |
super(owner, title, modalityType); |
136 |
init(); |
137 |
} |
138 |
|
139 |
|
140 |
public AboutDialog(Window owner, String title) { |
141 |
super(owner, title); |
142 |
init(); |
143 |
} |
144 |
|
145 |
|
146 |
public AboutDialog(Window owner) { |
147 |
super(owner); |
148 |
init(); |
149 |
} |
150 |
|
151 |
|
152 |
private void init() { |
153 |
setContentPane(getJContentPane()); |
154 |
setTitle("About"); |
155 |
} |
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
@return |
162 |
|
163 |
private JPanel getJContentPane() { |
164 |
if (jContentPane == null) { |
165 |
jContentPane = new JPanel(); |
166 |
jContentPane.setLayout(new BoxLayout(getJContentPane(), BoxLayout.Y_AXIS)); |
167 |
jContentPane.add(getTabbedPane(), null); |
168 |
jContentPane.add(getButtonPanel(), null); |
169 |
} |
170 |
return jContentPane; |
171 |
} |
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
@return |
178 |
|
179 |
private JPanel getButtonPanel() { |
180 |
if (buttonPanel == null) { |
181 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
182 |
gridBagConstraints3.insets = new Insets(3, 3, 3, 3); |
183 |
gridBagConstraints3.weighty = 1.0; |
184 |
gridBagConstraints3.weightx = 1.0; |
185 |
buttonPanel = new JPanel(); |
186 |
buttonPanel.setLayout(new GridBagLayout()); |
187 |
buttonPanel.add(getCloseButton(), gridBagConstraints3); |
188 |
} |
189 |
return buttonPanel; |
190 |
} |
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
@return |
197 |
|
198 |
private JButton getCloseButton() { |
199 |
if (closeButton == null) { |
200 |
closeButton = new JButton(); |
201 |
closeButton.setText("Close"); |
202 |
closeButton.addActionListener(new java.awt.event.ActionListener() { |
203 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
204 |
setVisible(false); |
205 |
} |
206 |
}); |
207 |
} |
208 |
return closeButton; |
209 |
} |
210 |
|
211 |
|
212 |
protected JTabbedPane getTabbedPane() { |
213 |
if (tabbedPane == null) { |
214 |
tabbedPane = new JTabbedPane(); |
215 |
} |
216 |
return tabbedPane; |
217 |
} |
218 |
|
219 |
|
220 |
protected void addTab(String title, Icon icon, Component component, String tip) { |
221 |
getTabbedPane().addTab(title, icon, component, tip); |
222 |
} |
223 |
|
224 |
|
225 |
protected void addScrolledTab(String title, Icon icon, Component component, String tip) { |
226 |
addTab(title, icon, new JScrollPane(component), tip); |
227 |
} |
228 |
|
229 |
|
230 |
protected void addTab(String title, Icon icon, String contentType, String content, String tip) { |
231 |
JEditorPane editorPane = new JEditorPane(); |
232 |
editorPane.setContentType(contentType); |
233 |
editorPane.setText(content); |
234 |
editorPane.setCaretPosition(0); |
235 |
editorPane.setEditable(false); |
236 |
editorPane.addHyperlinkListener(hyperlinkListener); |
237 |
|
238 |
addScrolledTab(title, icon, editorPane, tip); |
239 |
} |
240 |
} |