import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Date;
import java.text.DateFormat;
import javax.swing.BorderFactory;

/**
  *
  * Beschreibung
  *
  * @version 1.0 vom 08.06.2007
  * @author Nicholas Ohs
  */

public class GuiUhrZeit extends JFrame {
  // Anfang Variablen
  private JLabel lb_Uhrzeit = new JLabel();
  private JScrollPane jScrollPaneta_Ausgabe = new JScrollPane();
  private JTextArea ta_Ausgabe = new JTextArea("");
  private JButton bt_Start = new JButton();
  // Ende Variablen

  public GuiUhrZeit(String title) {
    // Frame-Initialisierung
    super(title);
    addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent evt) { System.exit(0); }
    });
    int frameWidth = 300;
    int frameHeight = 300;
    setSize(frameWidth, frameHeight);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (d.width - getSize().width) / 2;
    int y = (d.height - getSize().height) / 2 ;
    setLocation(x, y);
    Container cp = getContentPane();
    cp.setLayout(null);
    // Anfang Komponenten

    lb_Uhrzeit.setBounds(80, 48, 124, 24);
    lb_Uhrzeit.setText("lb_Uhrzeit");
    lb_Uhrzeit.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
    lb_Uhrzeit.setBorder(BorderFactory.createLoweredBevelBorder());
    cp.add(lb_Uhrzeit);
    jScrollPaneta_Ausgabe.setBounds(8, 120, 273, 145);
    ta_Ausgabe.setText("Es geht alles, drück nur den Button\n");
    jScrollPaneta_Ausgabe.setViewportView(ta_Ausgabe);
    cp.add(jScrollPaneta_Ausgabe);
    bt_Start.setBounds(64, 96, 153, 17);
    bt_Start.setText("Los Geht's!");
    cp.add(bt_Start);
    bt_Start.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        bt_StartActionPerformed(evt);
      }
    });

    // Ende Komponenten

    setResizable(false);
    setVisible(true);
    
    
    
    
    
    
    //////
    //Hier die Uhrzeit
    new Thread( new Runnable()
    {
      public void run()
      {
        while ( true )
        {
          try
          {
            Date date = new Date();
            DateFormat format = DateFormat.getTimeInstance();
            lb_Uhrzeit.setText( format.format(date) );
            Thread.sleep( 1000 );
          }
          catch ( InterruptedException e ) { }
        }
      }
    }).start();
    
    
  }

  // Anfang Ereignisprozeduren
  public void bt_StartActionPerformed(ActionEvent evt) {
      ta_Ausgabe.append("\nEs geht immer noch");
  }

  // Ende Ereignisprozeduren

  public static void main(String[] args) {
    new GuiUhrZeit("GuiUhrZeit");
  }
}

