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

/**
  *
  * description
  *
  * @version 1.0 from 06.10.2018
  * @author 
  */

public class XYDiagrammGUI extends JFrame {
  // Anfang Attribute
  private JButton bXYDiagrammzeichnen = new JButton();
  private PictureViewer imagePanel1 = new PictureViewer();

  private XYDiagramm bild;
  private Picture b;
  // Ende Attribute

  public XYDiagrammGUI (String title) {
    super (title);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    int frameWidth = 768; 
    int frameHeight = 551;
    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
    bXYDiagrammzeichnen.setBounds(280, 456, 209, 33);
    bXYDiagrammzeichnen.setText("XY-Diagramm zeichnen");
    bXYDiagrammzeichnen.setMargin(new Insets(2, 2, 2, 2));
    bXYDiagrammzeichnen.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent evt) { 
        bXYDiagrammzeichnen_ActionPerformed(evt);
      }
    });
    cp.add(bXYDiagrammzeichnen);
    imagePanel1.setBounds(24, 16, 705, 409);
    cp.add(imagePanel1);

    b = new Picture(700,800);
     imagePanel1.setImage(b);
    b.setObserver(imagePanel1);
    addWindowListener(new WindowAdapter() { 
      public void windowClosed(WindowEvent evt) { 
        BalkendiagrammGUI_WindowClosed(evt);
      }
    });
    // Ende Komponenten
    setResizable(false);
    setVisible(true);
  }

  // Anfang Methoden
  public void bXYDiagrammzeichnen_ActionPerformed(ActionEvent evt) {
    bild = new XYDiagramm();
    imagePanel1.setImage(bild);
    bild.setObserver(imagePanel1);
    imagePanel1.getVerticalScrollBar().setValue(10);
    imagePanel1.getVerticalScrollBar().setValue(0);
    imagePanel1.getViewport().repaint();
  } // end of bXYDiagrammzeichnen_ActionPerformed

  public void BalkendiagrammGUI_WindowClosed(WindowEvent evt) {
    
    
  } // end of BalkendiagrammGUI_WindowClosed

  // Ende Methoden

  public static void main(String[] args) {
    new XYDiagrammGUI("XYDiagrammGUI");
  }
}

