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


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


public class and_or_bsp1 extends JFrame {

  JButton Bn1 = new JButton("Setzen");
  JButton Bn2 = new JButton("löschen");
  JButton Bn3 = new JButton("Abfrage");
  JButton Bn4 = new JButton("Bn4");
  JButton BnOk = new JButton("Ok");
  JButton BnEsc = new JButton("Abbruch");


  private JTextArea editor;


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

  private void setGUI() {
    setSize(800, 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() );
    editor = new JTextArea();
    editor.setFont( new Font("Arial", Font.BOLD,18)  );
    //jpanel.setBackground(Color.red);
    this.getContentPane().add( new JScrollPane(editor), 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 );

          Bn1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              Bn1_Click();
            }
          });
          Bn2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              Bn2_Click();
            }
          });
          Bn3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              Bn3_Click();
            }
          });
          Bn4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              Bn4_Click();
            }
          });
          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 Bn1_Click() {
       int x=3;
	   int y = x | 36;  // 36 = 32+4  
       editor.setText("Ergebnis : "+y);
    }
     // löschen
    private void Bn2_Click() {
       int x  = 88;
       editor.setText("Ergebnis : "+x);
       int x2 = 16;
       editor.append("\nx2 : "+x2);
       editor.append("\n!x2 : "+~x2);
       int y = x & ~x2;
       editor.append("\nErgebnis : "+y);
// 1001000
    }

    private void Bn3_Click() {
       String erg="hallo";
       int x=255;
       int y = x & 8;
       if (y==8) 
        editor.setText("Bit 3 gesetzt");
       else
        editor.setText("Bit 3 nicht gesetzt");
    }
    private void Bn4_Click() {
       String erg="hallo";
       int x=67;
    }
    private void BnOk_Click() {
        System.out.println("Hier in Ok");
    }

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







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

}  // and_or


