OSDN Git Service

7e401f640a9b1dd96632d512710555880ecc05a1
[hayashilib/hayashi.git] / src / jp / co / areaweb / tools / gui / AboutDialog.java
1 package jp.co.areaweb.tools.gui;\r
2 import java.awt.*;\r
3 \r
4 @SuppressWarnings("serial")\r
5 public class AboutDialog extends Dialog\r
6 {\r
7     //{{DECLARE_CONTROLS\r
8     java.awt.Label label1;\r
9     java.awt.Button okButton;\r
10     java.awt.Label label2;\r
11     //}}\r
12 \r
13     // Used for addNotify redundency check.\r
14     boolean fComponentsAdjusted = false;\r
15 \r
16     class SymWindow extends java.awt.event.WindowAdapter\r
17     {\r
18         public void windowClosing(java.awt.event.WindowEvent event)\r
19         {\r
20             Object object = event.getSource();\r
21             if (object == AboutDialog.this)\r
22                 AboutDialog_WindowClosing(event);\r
23         }\r
24     }\r
25 \r
26     class SymAction implements java.awt.event.ActionListener\r
27     {\r
28         public void actionPerformed(java.awt.event.ActionEvent event)\r
29         {\r
30             Object object = event.getSource();\r
31             if (object == okButton)\r
32                 okButton_Clicked(event);\r
33         }\r
34     }\r
35 \r
36     public AboutDialog(Frame parent, boolean modal)\r
37     {\r
38         super(parent, modal);\r
39 \r
40         // This code is automatically generated by Visual Cafe when you add\r
41         // components to the visual environment. It instantiates and initializes\r
42         // the components. To modify the code, only use code syntax that matches\r
43         // what Visual Cafe can generate, or Visual Cafe may be unable to back\r
44         // parse your Java file into its visual environment.\r
45 \r
46 \r
47         //{{INIT_CONTROLS\r
48         setLayout(null);\r
49         setVisible(false);\r
50         setSize(360,114);\r
51         label1 = new java.awt.Label(Manager.PROGRAM_NAME +" Version "+ Manager.PROGRAM_VARSION +" ("+ Manager.PROGRAM_UPDATE +")", Label.CENTER);\r
52         label1.setBounds(10,10,340,20);\r
53         add(label1);\r
54         okButton = new java.awt.Button();\r
55         okButton.setLabel("OK");\r
56         okButton.setBounds(145,65,66,27);\r
57         add(okButton);\r
58         label2 = new java.awt.Label("All rights reserved.Copyright(c) 2006,, TDOS.",Label.CENTER);\r
59         label2.setBounds(10,40,340,20);\r
60         add(label2);\r
61         setTitle("AboutDialog");\r
62         //}}\r
63 \r
64         //{{REGISTER_LISTENERS\r
65         SymWindow aSymWindow = new SymWindow();\r
66         this.addWindowListener(aSymWindow);\r
67         SymAction lSymAction = new SymAction();\r
68         okButton.addActionListener(lSymAction);\r
69         //}}\r
70 \r
71     }\r
72 \r
73     public AboutDialog(Frame parent, String title, boolean modal)\r
74     {\r
75         this(parent, modal);\r
76         setTitle(title);\r
77     }\r
78 \r
79     public void addNotify()\r
80     {\r
81         // Record the size of the window prior to calling parents addNotify.\r
82 \r
83         super.addNotify();\r
84 \r
85         // Only do this once.\r
86         if (fComponentsAdjusted)\r
87             return;\r
88 \r
89         // Adjust components according to the insets\r
90         setSize(getInsets().left + getInsets().right + getSize().width, getInsets().top + getInsets().bottom + getSize().height);\r
91         Component components[] = getComponents();\r
92         for (int i = 0; i < components.length; i++)\r
93         {\r
94             Point p = components[i].getLocation();\r
95             p.translate(getInsets().left, getInsets().top);\r
96             components[i].setLocation(p);\r
97         }\r
98 \r
99         // Used for addNotify check.\r
100         fComponentsAdjusted = true;\r
101     }\r
102 \r
103     /**\r
104     * Shows or hides the component depending on the boolean flag b.\r
105     * @param b  if true, show the component; otherwise, hide the component.\r
106     * @see java.awt.Component#isVisible\r
107     */\r
108     public void setVisible(boolean b)\r
109     {\r
110         if(b)\r
111         {\r
112             Rectangle bounds = getParent().getBounds();\r
113             Rectangle abounds = getBounds();\r
114             setLocation(bounds.x + (bounds.width - abounds.width)/ 2,\r
115             bounds.y + (bounds.height - abounds.height)/2);\r
116         }\r
117         super.setVisible(b);\r
118     }\r
119 \r
120     void AboutDialog_WindowClosing(java.awt.event.WindowEvent event)\r
121     {\r
122         dispose();\r
123     }\r
124 \r
125     void okButton_Clicked(java.awt.event.ActionEvent event)\r
126     {\r
127         //{{CONNECTION\r
128         // Clicked from okButton Hide the Dialog\r
129         dispose();\r
130         //}}\r
131     }\r
132 }\r