KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > tool > common > InfoPanel


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  *
22  */

23 package org.enhydra.tool.common;
24
25 // Standard imports
26

27 import java.awt.*;
28 import java.beans.*;
29 import javax.swing.*;
30 import javax.swing.border.Border JavaDoc;
31 import javax.swing.border.TitledBorder JavaDoc;
32 import java.util.ResourceBundle JavaDoc;
33
34 //
35

36 public class InfoPanel extends JPanel {
37     static ResourceBundle JavaDoc res =
38         ResourceBundle.getBundle ("org.enhydra.tool.common.Res"); // nores
39

40     //
41

42     private GridBagLayout layoutMain;
43     private JPanel panelUser;
44     private JPanel panelSystem;
45     private JPanel panelJava;
46     private JPanel panelClassPath;
47     private GridBagLayout layoutUser;
48     private GridBagLayout layoutSystem;
49     private GridBagLayout layoutJava;
50     private JLabel labelName;
51     private JLabel labelWorking;
52     private JLabel labelHome;
53     private JTextField textName;
54     private JTextField textWorking;
55     private JTextField textHome;
56     private JLabel labelSystemName;
57     private JLabel labelSystemArch;
58     private JTextField textSystemName;
59     private JTextField textSystemArch;
60     private JLabel labelJavaHome;
61     private JLabel labelVendor;
62     private JLabel labelVersion;
63     private JTextField textJavaHome;
64     private JTextField textVendor;
65     private JTextField textVersion;
66     private JTextArea textClassPath;
67     private JScrollPane scrollClassPath;
68     private BorderLayout layoutClassPath;
69
70     public InfoPanel () {
71         try {
72             jbInit ();
73             pmInit ();
74         } catch (Exception JavaDoc ex) {
75             ex.printStackTrace ();
76         }
77     }
78
79     private void pmInit () {
80         textHome.setText (System.getProperty ("user.home")); // nores
81
textWorking.setText (System.getProperty ("user.dir")); // nores
82
textName.setText (System.getProperty ("user.name")); // nores
83
textSystemName.setText (System.getProperty ("os.name")); // nores
84
textSystemArch.setText (System.getProperty ("os.arch")); // nores
85
textJavaHome.setText (System.getProperty ("java.home")); // nores
86
textVendor.setText (System.getProperty ("java.vendor")); // nores
87
textVersion.setText (System.getProperty ("java.version")); // nores
88
textClassPath.append (System.getProperty ("java.class.path")); // nores
89
}
90
91     private void jbInit () throws Exception JavaDoc {
92         layoutMain =
93             (GridBagLayout) Beans.instantiate (getClass ().getClassLoader (),
94                                                GridBagLayout.class.getName ());
95         panelUser = (JPanel) Beans.instantiate (getClass ().getClassLoader (),
96                                                 JPanel.class.getName ());
97         panelSystem =
98             (JPanel) Beans.instantiate (getClass ().getClassLoader (),
99                                         JPanel.class.getName ());
100         panelJava = (JPanel) Beans.instantiate (getClass ().getClassLoader (),
101                                                 JPanel.class.getName ());
102         panelClassPath =
103             (JPanel) Beans.instantiate (getClass ().getClassLoader (),
104                                         JPanel.class.getName ());
105         layoutUser =
106             (GridBagLayout) Beans.instantiate (getClass ().getClassLoader (),
107                                                GridBagLayout.class.getName ());
108         layoutSystem =
109             (GridBagLayout) Beans.instantiate (getClass ().getClassLoader (),
110                                                GridBagLayout.class.getName ());
111         layoutJava =
112             (GridBagLayout) Beans.instantiate (getClass ().getClassLoader (),
113                                                GridBagLayout.class.getName ());
114         labelName = (JLabel) Beans.instantiate (getClass ().getClassLoader (),
115                                                 JLabel.class.getName ());
116         labelWorking =
117             (JLabel) Beans.instantiate (getClass ().getClassLoader (),
118                                         JLabel.class.getName ());
119         labelHome = (JLabel) Beans.instantiate (getClass ().getClassLoader (),
120                                                 JLabel.class.getName ());
121         textName =
122             (JTextField) Beans.instantiate (getClass ().getClassLoader (),
123                                             JTextField.class.getName ());
124         textWorking =
125             (JTextField) Beans.instantiate (getClass ().getClassLoader (),
126                                             JTextField.class.getName ());
127         textHome =
128             (JTextField) Beans.instantiate (getClass ().getClassLoader (),
129                                             JTextField.class.getName ());
130         labelSystemName =
131             (JLabel) Beans.instantiate (getClass ().getClassLoader (),
132                                         JLabel.class.getName ());
133         labelSystemArch =
134             (JLabel) Beans.instantiate (getClass ().getClassLoader (),
135                                         JLabel.class.getName ());
136         textSystemName =
137             (JTextField) Beans.instantiate (getClass ().getClassLoader (),
138                                             JTextField.class.getName ());
139         textSystemArch =
140             (JTextField) Beans.instantiate (getClass ().getClassLoader (),
141                                             JTextField.class.getName ());
142         labelJavaHome =
143             (JLabel) Beans.instantiate (getClass ().getClassLoader (),
144                                         JLabel.class.getName ());
145         labelVendor =
146             (JLabel) Beans.instantiate (getClass ().getClassLoader (),
147                                         JLabel.class.getName ());
148         labelVersion =
149             (JLabel) Beans.instantiate (getClass ().getClassLoader (),
150                                         JLabel.class.getName ());
151         textJavaHome =
152             (JTextField) Beans.instantiate (getClass ().getClassLoader (),
153                                             JTextField.class.getName ());
154         textVendor =
155             (JTextField) Beans.instantiate (getClass ().getClassLoader (),
156                                             JTextField.class.getName ());
157         textVersion =
158             (JTextField) Beans.instantiate (getClass ().getClassLoader (),
159                                             JTextField.class.getName ());
160         textClassPath =
161             (JTextArea) Beans.instantiate (getClass ().getClassLoader (),
162                                            JTextArea.class.getName ());
163
164         // User
165

166         layoutClassPath =
167             (BorderLayout) Beans.instantiate (getClass ().getClassLoader (),
168                                               BorderLayout.class.getName ());
169
170         labelName.setText (res.getString ("Name_"));
171         labelWorking.setText (res.getString ("Working_directory_"));
172         labelHome.setText (res.getString ("Home_directory_"));
173         textName.setEditable (false);
174         textWorking.setEditable (false);
175         textHome.setEditable (false);
176         panelUser.setLayout (layoutUser);
177         panelUser.setBorder (BorderFactory.createTitledBorder (res.getString ("User")));
178         labelJavaHome.setText (res.getString ("Java_home_"));
179         labelVendor.setText (res.getString ("Vendor_"));
180         labelVersion.setText (res.getString ("Version_"));
181         textJavaHome.setEditable (false);
182         textVendor.setEditable (false);
183         textVersion.setEditable (false);
184         textClassPath.setLineWrap (true);
185         textClassPath.setWrapStyleWord (true);
186         panelUser.add (labelName,
187                        new GridBagConstraints (0, 0, 1, 1, 0.0, 0.0,
188                                                GridBagConstraints.WEST,
189                                                GridBagConstraints.HORIZONTAL,
190                                                new Insets (5, 5, 2, 5), 0,
191                                                0));
192         panelUser.add (labelWorking,
193                        new GridBagConstraints (0, 1, 1, 1, 0.0, 0.0,
194                                                GridBagConstraints.WEST,
195                                                GridBagConstraints.HORIZONTAL,
196                                                new Insets (2, 5, 2, 5), 0,
197                                                0));
198         panelUser.add (labelHome,
199                        new GridBagConstraints (0, 2, 1, 1, 0.0, 0.0,
200                                                GridBagConstraints.WEST,
201                                                GridBagConstraints.HORIZONTAL,
202                                                new Insets (2, 5, 5, 5), 0,
203                                                0));
204         panelUser.add (textName,
205                        new GridBagConstraints (1, 0, 1, 1, 0.1, 0.0,
206                                                GridBagConstraints.WEST,
207                                                GridBagConstraints.HORIZONTAL,
208                                                new Insets (5, 5, 2, 5), 100,
209                                                0));
210         panelUser.add (textWorking,
211                        new GridBagConstraints (1, 1, 1, 1, 0.1, 0.0,
212                                                GridBagConstraints.WEST,
213                                                GridBagConstraints.HORIZONTAL,
214                                                new Insets (2, 5, 2, 5), 100,
215                                                0));
216         panelUser.add (textHome,
217                        new GridBagConstraints (1, 2, 1, 1, 0.1, 0.0,
218                                                GridBagConstraints.WEST,
219                                                GridBagConstraints.HORIZONTAL,
220                                                new Insets (2, 5, 5, 5), 0,
221                                                0));
222
223         // System
224

225         labelSystemName.setText (res.getString ("Operating_system_"));
226         labelSystemArch.setText (res.getString ("Architecture_"));
227         textSystemName.setEditable (false);
228         textSystemArch.setEditable (false);
229         panelSystem.setLayout (layoutSystem);
230         panelSystem.setBorder (BorderFactory.createTitledBorder (res.getString ("System")));
231         panelSystem.add (labelSystemName,
232                          new GridBagConstraints (0, 0, 1, 1, 0.0, 0.0,
233                                                  GridBagConstraints.WEST,
234                                                  GridBagConstraints.HORIZONTAL,
235                                                  new Insets (5, 5, 2, 5), 0,
236                                                  0));
237         panelSystem.add (labelSystemArch,
238                          new GridBagConstraints (0, 1, 1, 1, 0.0, 0.0,
239                                                  GridBagConstraints.WEST,
240                                                  GridBagConstraints.HORIZONTAL,
241                                                  new Insets (2, 5, 5, 5), 0,
242                                                  0));
243         panelSystem.add (textSystemName,
244                          new GridBagConstraints (1, 0, 1, 1, 0.1, 0.0,
245                                                  GridBagConstraints.WEST,
246                                                  GridBagConstraints.HORIZONTAL,
247                                                  new Insets (5, 5, 2, 5),
248                                                  100, 0));
249         panelSystem.add (textSystemArch,
250                          new GridBagConstraints (1, 1, 1, 1, 0.1, 0.0,
251                                                  GridBagConstraints.WEST,
252                                                  GridBagConstraints.HORIZONTAL,
253                                                  new Insets (2, 5, 5, 5),
254                                                  100, 0));
255
256         // Java
257

258         panelJava.setLayout (layoutJava);
259         panelJava.setBorder (BorderFactory.createTitledBorder (res.getString ("Java")));
260         panelJava.add (labelJavaHome,
261                        new GridBagConstraints (0, 0, 1, 1, 0.0, 0.0,
262                                                GridBagConstraints.WEST,
263                                                GridBagConstraints.HORIZONTAL,
264                                                new Insets (5, 5, 2, 5), 40,
265                                                0));
266         panelJava.add (labelVendor,
267                        new GridBagConstraints (0, 1, 1, 1, 0.0, 0.0,
268                                                GridBagConstraints.WEST,
269                                                GridBagConstraints.HORIZONTAL,
270                                                new Insets (2, 5, 2, 5), 0,
271                                                0));
272         panelJava.add (labelVersion,
273                        new GridBagConstraints (0, 2, 1, 1, 0.0, 0.0,
274                                                GridBagConstraints.WEST,
275                                                GridBagConstraints.HORIZONTAL,
276                                                new Insets (2, 5, 5, 5), 0,
277                                                0));
278         panelJava.add (textJavaHome,
279                        new GridBagConstraints (1, 0, 1, 1, 0.1, 0.0,
280                                                GridBagConstraints.WEST,
281                                                GridBagConstraints.HORIZONTAL,
282                                                new Insets (5, 5, 2, 5), 100,
283                                                0));
284         panelJava.add (textVendor,
285                        new GridBagConstraints (1, 1, 1, 1, 0.1, 0.0,
286                                                GridBagConstraints.WEST,
287                                                GridBagConstraints.HORIZONTAL,
288                                                new Insets (2, 5, 2, 5), 100,
289                                                0));
290         panelJava.add (textVersion,
291                        new GridBagConstraints (1, 2, 1, 1, 0.1, 0.0,
292                                                GridBagConstraints.WEST,
293                                                GridBagConstraints.HORIZONTAL,
294                                                new Insets (2, 5, 5, 5), 100,
295                                                0));
296
297         // CLASSPATH
298

299         panelClassPath.setBorder (BorderFactory.createTitledBorder (res.getString ("Class_Path")));
300         panelClassPath.setLayout (layoutClassPath);
301         textClassPath.setEditable (false);
302         textClassPath.setRows (5);
303
304         scrollClassPath = new JScrollPane (textClassPath);
305
306         panelClassPath.add (scrollClassPath, BorderLayout.CENTER);
307
308         // MAIN
309

310         this.setMaximumSize (new Dimension (600, 440));
311         this.setMinimumSize (new Dimension (600, 440));
312         this.setPreferredSize (new Dimension (600, 440));
313         this.setLayout (layoutMain);
314         this.add (panelUser,
315                   new GridBagConstraints (0, 0, 1, 1, 0.1, 0.1,
316                                           GridBagConstraints.CENTER,
317                                           GridBagConstraints.BOTH,
318                                           new Insets (5, 5, 2, 5), 0, 0));
319         this.add (panelSystem,
320                   new GridBagConstraints (0, 1, 1, 1, 0.1, 0.1,
321                                           GridBagConstraints.CENTER,
322                                           GridBagConstraints.BOTH,
323                                           new Insets (2, 5, 2, 5), 0, 0));
324         this.add (panelJava,
325                   new GridBagConstraints (0, 2, 1, 1, 0.1, 0.1,
326                                           GridBagConstraints.CENTER,
327                                           GridBagConstraints.BOTH,
328                                           new Insets (2, 5, 2, 5), 0, 0));
329         this.add (panelClassPath,
330                   new GridBagConstraints (0, 3, 1, 1, 0.1, 0.1,
331                                           GridBagConstraints.CENTER,
332                                           GridBagConstraints.BOTH,
333                                           new Insets (2, 5, 5, 5), 10, 60));
334     }
335
336 }
337
338
Popular Tags