//Titel:            Dialog-Fenster
//Version:
//Copyright:		Copyright (c) 2010
//Autor:
//Organisation:
//Beschreibung:


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


public class invokelater1 extends JFrame implements ActionListener {

  Timer myTimer;  // Timer

  JButton BnUp = new JButton("Up");
  JButton BnTimer = new JButton("Timer");
  JButton BnEsc = new JButton("Abbruch");
  JProgressBar bar = new JProgressBar();

  public invokelater1() {
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setGUI();
  }

  private void setGUI() {
    setSize(400, 230);
    setTitle("JFrame als Dialog");

    BnUp.setFont( new Font("Arial", Font.BOLD,18)  );
    BnTimer.setFont( new Font("Arial", Font.BOLD,18)  );
    BnEsc.setFont( new Font("Arial", Font.BOLD,18)  );
    BnUp.setPreferredSize( BnEsc.getPreferredSize() );

    this.getContentPane().setLayout( new BorderLayout() );

	JPanel pnButton = new JPanel();
	//pnButton.setBackground(Color.red);
	pnButton.setLayout( new FlowLayout() );
	pnButton.add(BnUp);
	pnButton.add(BnTimer);
	pnButton.add(BnEsc);

    this.getContentPane().add( bar, BorderLayout.CENTER );
    this.getContentPane().add( pnButton, BorderLayout.SOUTH );

    BnUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              BnUp_Click();
            }
          });

    BnTimer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              BnTimer_Click();
            }
          });


    BnEsc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              BnEsc_Click();
            }
          });

  } // setGUI

    private void BnUp_Click() {
        System.out.println("Hier in Ok");
       bar.setValue( bar.getValue()+1 );
    }

   private void BnTimer_Click() {
     bar.setMaximum(1000);
     bar.setStringPainted(true);
     // bar.setIndeterminate(true);  // ohne Maximalwert


     myTimer = new Timer(100, this); // 500 ms
     myTimer.start();  // starten
   }

   public void actionPerformed(ActionEvent e) {
      bar.setValue( bar.getValue()+1 );
   }  // actionperformed

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

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

}  // invokelater1

class myThread extends Thread {

  JProgressBar bar;

  public myThread(JProgressBar bar) {
   this.bar = bar;
  }

  public void run() {
  }
}