KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSmoothPropertiesDisplayer


1 /*
2  * Frame.java
3  *
4  * Created on 10 août 2003, 19:23
5  */

6
7 import java.util.*;
8
9
10 /**
11  *
12  * @author Rodrigo
13  */

14 public class JSmoothPropertiesDisplayer extends java.awt.Frame JavaDoc
15 {
16     private String JavaDoc[] m_args;
17     /** Creates new form Frame */
18     public JSmoothPropertiesDisplayer(String JavaDoc[] args)
19     {
20     m_args = args;
21         initComponents();
22         displayInformation();
23     }
24     
25     /** This method is called from within the constructor to
26      * initialize the form.
27      * WARNING: Do NOT modify this code. The content of this method is
28      * always regenerated by the Form Editor.
29      */

30     private void initComponents() {//GEN-BEGIN:initComponents
31
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
32
33         label1 = new java.awt.Label JavaDoc();
34         m_text = new java.awt.TextArea JavaDoc();
35         m_buttonClose = new java.awt.Button JavaDoc();
36
37         setLayout(new java.awt.GridBagLayout JavaDoc());
38
39         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
40             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
41                 exitForm(evt);
42             }
43         });
44
45         label1.setAlignment(java.awt.Label.CENTER);
46         label1.setFont(new java.awt.Font JavaDoc("Dialog", 0, 18));
47         label1.setText("JSmooth Sample Program");
48         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
49         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
50         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
51         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
52         add(label1, gridBagConstraints);
53
54         m_text.setEditable(false);
55         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
56         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
57         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
58         gridBagConstraints.weightx = 1.0;
59         gridBagConstraints.weighty = 1.0;
60         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 5, 5);
61         add(m_text, gridBagConstraints);
62
63         m_buttonClose.setLabel("Close");
64         m_buttonClose.addActionListener(new java.awt.event.ActionListener JavaDoc() {
65             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
66                 buttonCloseActionPerformed(evt);
67             }
68         });
69
70         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
71         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 5, 5);
72         add(m_buttonClose, gridBagConstraints);
73
74         pack();
75     }//GEN-END:initComponents
76

77     private void buttonCloseActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_buttonCloseActionPerformed
78
{//GEN-HEADEREND:event_buttonCloseActionPerformed
79
// Add your handling code here:
80
System.exit(0);
81     }//GEN-LAST:event_buttonCloseActionPerformed
82

83     /** Exit the Application */
84     private void exitForm(java.awt.event.WindowEvent JavaDoc evt)//GEN-FIRST:event_exitForm
85
{
86         System.exit(0);
87     }//GEN-LAST:event_exitForm
88

89     /**
90      * @param args the command line arguments
91      */

92     public static void main(String JavaDoc args[])
93     {
94         new JSmoothPropertiesDisplayer(args).setVisible(true);
95     }
96
97     private void displayInformation()
98     {
99         StringBuffer JavaDoc out = new StringBuffer JavaDoc();
100         out.append("-- Sample --\n\n");
101
102         out.append("Arguments passed on the command line: " + m_args.length + " \n");
103         for (int i=0; i<m_args.length; i++)
104             {
105             out.append("" + i + ". " + m_args[i]);
106             out.append("\n");
107             }
108         out.append("\n");
109
110         out.append("Free Heap Memory: " + Runtime.getRuntime().freeMemory() + " bytes\n");
111         // out.append("Max Heap Memory: " + Runtime.getRuntime().maxMemory() + " bytes\n");
112
out.append("Total Heap Memory: " + Runtime.getRuntime().totalMemory() + " bytes\n");
113         out.append("\n");
114
115         out.append("System Properties:\n\n");
116         Properties props = System.getProperties();
117         for (Enumeration e = props.propertyNames(); e.hasMoreElements(); )
118         {
119             String JavaDoc key = (String JavaDoc)e.nextElement();
120             out.append(key);
121             out.append(" = ");
122             out.append(props.getProperty(key));
123             out.append("\n");
124         }
125         System.out.println(out.toString());
126         m_text.setText(out.toString());
127     }
128     
129     // Variables declaration - do not modify//GEN-BEGIN:variables
130
private java.awt.Label JavaDoc label1;
131     private java.awt.Button JavaDoc m_buttonClose;
132     private java.awt.TextArea JavaDoc m_text;
133     // End of variables declaration//GEN-END:variables
134

135 }
136
Popular Tags