1 6 7 import java.util.*; 8 9 10 14 public class JSmoothPropertiesDisplayer extends java.awt.Frame 15 { 16 private String [] m_args; 17 18 public JSmoothPropertiesDisplayer(String [] args) 19 { 20 m_args = args; 21 initComponents(); 22 displayInformation(); 23 } 24 25 30 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 32 33 label1 = new java.awt.Label (); 34 m_text = new java.awt.TextArea (); 35 m_buttonClose = new java.awt.Button (); 36 37 setLayout(new java.awt.GridBagLayout ()); 38 39 addWindowListener(new java.awt.event.WindowAdapter () { 40 public void windowClosing(java.awt.event.WindowEvent evt) { 41 exitForm(evt); 42 } 43 }); 44 45 label1.setAlignment(java.awt.Label.CENTER); 46 label1.setFont(new java.awt.Font ("Dialog", 0, 18)); 47 label1.setText("JSmooth Sample Program"); 48 gridBagConstraints = new java.awt.GridBagConstraints (); 49 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 50 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 51 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 52 add(label1, gridBagConstraints); 53 54 m_text.setEditable(false); 55 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (5, 5, 5, 5); 61 add(m_text, gridBagConstraints); 62 63 m_buttonClose.setLabel("Close"); 64 m_buttonClose.addActionListener(new java.awt.event.ActionListener () { 65 public void actionPerformed(java.awt.event.ActionEvent evt) { 66 buttonCloseActionPerformed(evt); 67 } 68 }); 69 70 gridBagConstraints = new java.awt.GridBagConstraints (); 71 gridBagConstraints.insets = new java.awt.Insets (5, 5, 5, 5); 72 add(m_buttonClose, gridBagConstraints); 73 74 pack(); 75 } 77 private void buttonCloseActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); 81 } 83 84 private void exitForm(java.awt.event.WindowEvent evt) { 86 System.exit(0); 87 } 89 92 public static void main(String args[]) 93 { 94 new JSmoothPropertiesDisplayer(args).setVisible(true); 95 } 96 97 private void displayInformation() 98 { 99 StringBuffer out = new StringBuffer (); 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("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 key = (String )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 private java.awt.Label label1; 131 private java.awt.Button m_buttonClose; 132 private java.awt.TextArea m_text; 133 135 } 136 | Popular Tags |