import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
  *
  * Beschreibung
  *
  * @version 1.0 vom 20.10.2007
  * @author
  */

public class FlugzeugGUI extends JDialog {
  // Anfang Variablen
  private JLabel jLabelHersteller = new JLabel();
  private JLabel jLabelTyp = new JLabel();
  private JLabel jLabelSitzplaetze = new JLabel();
  private JTextField jTFHersteller = new JTextField();
  private JTextField jTFTyp = new JTextField();
  private JTextField jTFSitzplaetze = new JTextField();
  private JButton jButtonOK = new JButton();
  private JButton jButtonAbbrechen = new JButton();
  // Ende Variablen
  private Flugzeug dasFlugzeug;

  public FlugzeugGUI(JFrame owner, String title, boolean modal, Flugzeug f) {
    // Dialog-Initialisierung
    super(owner, title, modal);
    dasFlugzeug = f;
    addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent evt) { System.exit(0); }
    });
    int frameWidth = 613;
    int frameHeight = 496;
    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

    jLabelHersteller.setBounds(24, 56, 74, 16);
    jLabelHersteller.setText("Hersteller");
    jLabelHersteller.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
    cp.add(jLabelHersteller);
    jLabelTyp.setBounds(24, 88, 24, 16);
    jLabelTyp.setText("Typ");
    jLabelTyp.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
    cp.add(jLabelTyp);
    jLabelSitzplaetze.setBounds(24, 120, 73, 16);
    jLabelSitzplaetze.setText("Sitzplätze");
    jLabelSitzplaetze.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
    cp.add(jLabelSitzplaetze);
    jTFHersteller.setBounds(104, 56, 121, 24);
    jTFHersteller.setText("");
    cp.add(jTFHersteller);
    jTFTyp.setBounds(104, 88, 121, 24);
    jTFTyp.setText("");
    cp.add(jTFTyp);
    jTFSitzplaetze.setBounds(104, 120, 121, 24);
    jTFSitzplaetze.setText("");
    cp.add(jTFSitzplaetze);
    jButtonOK.setBounds(16, 176, 99, 25);
    jButtonOK.setText("OK");
    cp.add(jButtonOK);
    jButtonOK.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        jButtonOKActionPerformed(evt);
      }
    });

    jButtonAbbrechen.setBounds(128, 176, 99, 25);
    jButtonAbbrechen.setText("Abbrechen");
    cp.add(jButtonAbbrechen);
    jButtonAbbrechen.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        jButtonAbbrechenActionPerformed(evt);
      }
    });

    // Ende Komponenten

    setResizable(false);
    setVisible(true);
  }

  // Anfang Ereignisprozeduren
  public void jButtonOKActionPerformed(ActionEvent evt) {
     dasFlugzeug.setHersteller(jTFHersteller.getText());
     this.dispose();

  }

  public void jButtonAbbrechenActionPerformed(ActionEvent evt) {
     this.dispose();
  }

  // Ende Ereignisprozeduren
}

