1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.ximtec.igesture.geco.dialog;
28
29 import java.awt.Dimension;
30 import java.awt.event.MouseAdapter;
31 import java.awt.event.MouseEvent;
32 import java.io.IOException;
33 import java.net.URL;
34 import java.util.logging.Level;
35 import java.util.logging.Logger;
36
37 import javax.swing.JButton;
38 import javax.swing.JEditorPane;
39 import javax.swing.JScrollPane;
40 import javax.swing.plaf.basic.BasicHTML;
41
42 import org.sigtec.graphix.GuiBundle;
43 import org.sigtec.graphix.GuiTool;
44 import org.sigtec.graphix.widget.BasicDialog;
45 import org.ximtec.igesture.geco.util.Constant;
46 import org.ximtec.igesture.geco.util.GuiBundleTool;
47 import org.ximtec.igesture.graphics.SwingTool;
48
49
50
51
52
53
54
55
56
57 public class AboutDialog extends BasicDialog {
58
59 private static final Logger LOGGER = Logger.getLogger(AboutDialog.class
60 .getName());
61
62
63
64
65 public static final String KEY = "AboutDialog";
66 public static final String RESOURCE = "Resource";
67
68
69
70
71
72
73 public AboutDialog() {
74 super();
75 }
76
77
78
79
80
81
82
83
84 public AboutDialog(String key, GuiBundle guiBundle) {
85 super(key, guiBundle);
86 }
87
88
89
90
91
92
93
94
95 protected void init(String key, GuiBundle guiBundle) {
96 super.init(key, guiBundle);
97 int width = guiBundle.getWidth(key);
98 int height = guiBundle.getHeight(key);
99 JEditorPane aboutField;
100
101 try {
102 String resource = guiBundle.getProperty(key, RESOURCE);
103 URL path = AboutDialog.class.getClassLoader().getResource(resource);
104 aboutField = new JEditorPane(path);
105 aboutField.setEditable(false);
106 aboutField.setContentType("text/html");
107 aboutField.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,
108 Boolean.TRUE);
109 aboutField.putClientProperty(BasicHTML.documentBaseKey,
110 AboutDialog.class.getResource(Constant.SLASH));
111 aboutField.setPreferredSize(new Dimension(width - 10, height - 50));
112 JScrollPane scrollPane = new JScrollPane(aboutField);
113 scrollPane.setPreferredSize(new Dimension(width - 10, height - 50));
114 scrollPane.setAutoscrolls(true);
115 addComponent(scrollPane, SwingTool.createGridBagConstraint(0, 0));
116 }
117 catch (IOException e) {
118 LOGGER.log(Level.SEVERE, Constant.EMPTY_STRING, e);
119 }
120
121 JButton okButton = GuiTool.createButton(Constant.CLOSE_ABOUT_BUTTON, GuiBundleTool.getBundle());
122 okButton.addMouseListener(new MouseAdapter() {
123
124 @Override
125 public void mouseClicked(MouseEvent arg0) {
126 super.mouseClicked(arg0);
127 closeDialog();
128 }
129 });
130
131 addComponent(okButton, SwingTool.createGridBagConstraint(0, 1));
132 pack();
133 }
134
135
136 private void closeDialog() {
137 setVisible(false);
138 dispose();
139 }
140
141 }