import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

/**
  *
  * Beschreibung
  *
  * @version 1.0 vom 30.10.2010
  * @author
  */

public class CDGUI extends JDialog {
  // Anfang Attribute
  private JTextField jTFTitel = new JTextField();
  private JTextField jTFInterpret = new JTextField();
  private JLabel jLabel1 = new JLabel();
  private JLabel jLabel2 = new JLabel();
  private JButton jBOK = new JButton();
  private JButton jBAbbrechen = new JButton();
  private CD dieAngezeigteCD;
  // Ende Attribute

  public CDGUI(JFrame owner, String title, boolean modal) {
    // Dialog-Initialisierung
    super(owner, title, modal);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    int frameWidth = 340;
    int frameHeight = 306;
    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

    jTFTitel.setBounds(88, 40, 193, 32);
    jTFTitel.setText("jTFTitel");
    cp.add(jTFTitel);
    jTFInterpret.setBounds(88, 88, 193, 32);
    jTFInterpret.setText("jTFInterpret");
    cp.add(jTFInterpret);
    jLabel1.setBounds(24, 48, 36, 16);
    jLabel1.setText("Titel");
    jLabel1.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
    cp.add(jLabel1);
    jLabel2.setBounds(24, 96, 58, 16);
    jLabel2.setText("Interpret");
    jLabel2.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
    cp.add(jLabel2);
    jBOK.setBounds(24, 144, 115, 25);
    jBOK.setText("OK");
    jBOK.setMargin(new Insets(2, 2, 2, 2));
    jBOK.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        jBOK_ActionPerformed(evt);
      }
    });
    cp.add(jBOK);
    jBAbbrechen.setBounds(168, 144, 115, 25);
    jBAbbrechen.setText("Abbrechen");
    jBAbbrechen.setMargin(new Insets(2, 2, 2, 2));
    jBAbbrechen.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        jBAbbrechen_ActionPerformed(evt);
      }
    });
    cp.add(jBAbbrechen);
    // Ende Komponenten

    setResizable(false);
    // setVisible(true);
  }

  // Anfang Methoden
  
  public void anzeigen()
  {
    jTFTitel.setText(dieAngezeigteCD.getTitel());
    jTFInterpret.setText(dieAngezeigteCD.getInterpret());
    setVisible(true);
  }
  
  public void jBOK_ActionPerformed(ActionEvent evt) {
    dieAngezeigteCD.setTitel(jTFTitel.getText());
    dieAngezeigteCD.setInterpret(jTFInterpret.getText());
    dispose();
  }

  public void jBAbbrechen_ActionPerformed(ActionEvent evt) {
    dispose();
  }

  public CD getDieAngezeigteCD() {
    return dieAngezeigteCD;
  }

  public void setDieAngezeigteCD(CD dieAngezeigteCD) {
    this.dieAngezeigteCD = dieAngezeigteCD;
  }

  // Ende Methoden
}
