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


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


public class testInterface extends JFrame {

  JButton Bn1 = new JButton("Bn1");
  JButton Bn2 = new JButton("Bn2");
  JButton Bn3 = new JButton("Bn3");
  JButton Bn4 = new JButton("Bn4");
  JButton BnOk = new JButton("Ok");
  JButton BnEsc = new JButton("Abbruch");


  private JPanel jpanel;


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

  private void setGUI() {
    setSize(500, 430);
    setTitle("JFrame als Dialog");

    Bn1.setFont( new Font("Arial", Font.BOLD,18)  );
    Bn2.setFont( new Font("Arial", Font.BOLD,18)  );
    Bn3.setFont( new Font("Arial", Font.BOLD,18)  );
    Bn4.setFont( new Font("Arial", Font.BOLD,18)  );
    BnOk.setFont( new Font("Arial", Font.BOLD,18)  );
    BnEsc.setFont( new Font("Arial", Font.BOLD,18)  );
    BnOk.setPreferredSize( BnEsc.getPreferredSize() );

    this.getContentPane().setLayout( new BorderLayout() );
    jpanel = new JPanel();
    jpanel.setBackground(Color.red);
    this.getContentPane().add( new JScrollPane(jpanel), BorderLayout.CENTER);

	JPanel pnButton = new JPanel();
	//pnButton.setBackground(Color.red);
	pnButton.setLayout( new FlowLayout() );
	pnButton.add(Bn1);
	pnButton.add(Bn2);
	pnButton.add(Bn3);
	pnButton.add(Bn4);
	pnButton.add(BnOk);
	pnButton.add(BnEsc);

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

          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();
            }
          });


  } // setGUI

    private void BnOk_Click() {
        C1 c1 = new C1();
        C2 c2 = new C2(123.5667);
        C2 c3 = new C2("mi",-1234.677);
        c1.print();
        c2.print();
        c3.print();
        IMI [] feld = new IMI[3];
        feld[0] = c1;
        feld[1] = c2;
        feld[2] = c3;
        System.out.println("\n for-schleife");

        for (int i=0; i< feld.length; i++) 
           feld[i].print();
        System.out.println("\n for-schleife");
        for (IMI imi : feld) 
           imi.print();
        ArrayList<IMI> felder = new ArrayList<IMI>;
    }

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







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

}  // testInterface


interface IMI {
  void print();
}

class C1 implements IMI {
  int i=11;

  public void print() {
    System.out.println("i: "+i);
   }
}

 
class C2 implements IMI {
  double d=123.445;
  String name;

  public C2(double d) {
    this("",d);
  }
  public C2(String name, double d) {
    this.d = d;
    this.name = name;
  }

  public void print() {
    System.out.println("d: "+d);
   }
}

 
  