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 BalkendiagrammGUI extends JFrame {
  // Anfang Attribute
  private JButton bZeichnen = new JButton();
  private PictureViewer imagePanel1 = new PictureViewer();

  // Ende Attribute

  public BalkendiagrammGUI (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
    bZeichnen.setBounds(256, 456, 273, 33);
    bZeichnen.setText("Balkendiagramm zeichnen");
    bZeichnen.setMargin(new Insets(2, 2, 2, 2));
    bZeichnen.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent evt) { 
        bZeichnen_ActionPerformed(evt);
      }
    });
    cp.add(bZeichnen);
    imagePanel1.setBounds(24, 16, 705, 409);
    cp.add(imagePanel1);

    // Ende Komponenten
    setResizable(false);
    setVisible(true);
  }

  // Anfang Methoden
  public void bZeichnen_ActionPerformed(ActionEvent evt) {
    Balkendiagramm bild = new Balkendiagramm();
    imagePanel1.setImage(bild);
    imagePanel1.getViewport().repaint();
    imagePanel1.getVerticalScrollBar().setValue(1);
    imagePanel1.getVerticalScrollBar().setValue(0);    
  } // end of bZeichnen_ActionPerformed

  // Ende Methoden

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

