/* Autor:           Dipl.-Inf., Dipl.-Ing. (FH) Michael Wilhelm
   Firma:           HS Harz, FB AI
   EMail:           mwilhelm@hs-harz.de
   Projekt:         Demo
   Version:         0.8
   Ersterstellung:  10.10.2006
   Letzte Änderung: 23.10.2010
*/


// Dialogfenster, um Einstellungen vorzunehmen
// nur das Gerüst fertig

import java.awt.*;
import javax.swing.*;

import java.awt.event.*;



// Anzeige der Eigenschaften im Package System

// Anzeige der Eigenschaften im Package Runtime.getRuntime()

public class System01 extends JFrame {

      JTextArea _editor;

    /** Creates a new instance of JDSystem */
    public System01() {
        setSize(600, 400);
        setTitle("System-Einstellungen");
        setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        setGUI();
        createData();
        // setVisible(true);
    }


    private void setGUI() {
        this.getContentPane().setLayout( new GridBagLayout() );

        JLabel label1 = new JLabel("System-Einstellungen");
        label1.setFont( new Font("Arial", Font.BOLD,16)  );
        this.getContentPane().add( label1,  
                new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
                ,GridBagConstraints.WEST, GridBagConstraints.NONE, 
                new Insets(20,10,0,10), 0, 0));
        
        
        _editor = new JTextArea();
        _editor.setFont( new Font("Arial", Font.BOLD,14)  );        
        
        this.getContentPane().add( new JScrollPane(_editor),  
                new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0
                ,GridBagConstraints.EAST, GridBagConstraints.BOTH, 
                new Insets(5,10,0,10), 0, 0));
        
        JButton BnOk = new JButton("Ok");
        JButton BnESC = new JButton("Abbruch");
        
        BnOk.setFont( new Font("Arial", Font.BOLD,14)  );        
        BnESC.setFont( new Font("Arial", Font.BOLD,14)  );        

    
        JPanel panelBn = new JPanel();
        panelBn.add(BnOk);
        panelBn.add(BnESC);


        this.getContentPane().add(panelBn,  
                new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0
                ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, 
                new Insets(30,0,0,0), 0, 0));

        BnOk.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            BnOk_Click();
          }
        });
        
        BnESC.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            BnESC_Click();
          }
        });
        
    }

    // java.lang.System
  private void createData() {
    addProperties("java.version");
    addProperties("java.vendor");
    addProperties("java.home");
    addProperties("java.vm.specification.version");
    addProperties("java.vm.specification.vendor");
    addProperties("java.vm.specification.name");
    addProperties("java.vm.version");
    addProperties("java.vm.vendor");
    addProperties("java.vm.name");
    addProperties("java.specification.version");
    addProperties("java.specification.vendor");
    addProperties("java.specification.name");
    addProperties("java.class.version");
    addProperties("java.class.path");
    addProperties("os.name");
    addProperties("os.arch");
    addProperties("os.version");
    addProperties("file.separator");
    addProperties("path.separator");
    addProperties("line.separator");
    addProperties("user.name");
    addProperties("user.home");
    addProperties("user.dir");

    long mem = Runtime.getRuntime().totalMemory();
    _editor.append("\n\nSpeicher in der JVM:  "+Long.toString(mem)+" Bytes");


    //Runtime.totalMemory();
  }

  private void addProperties(String sItem) {
    String res = System.getProperty(sItem);
    _editor.append(sItem+":  "+res+"\n");
  }

    private void BnESC_Click() {
      System.exit(0);
    }

    // jetzt noch mit keiner Plausibilitätsprüfung
    private void BnOk_Click() {
      System.exit(0);
    }



  public static void main(String[] args) {
    System01 frame = new System01();
    frame.setVisible(true);
  }



}
