import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Graphics;
import java.awt.geom.*;
public class Main extends JFrame implements ActionListener {
	LevelElements level;
	Container c = getContentPane();
	JPanel mainPane = new JPanel();
	JPanel optionPane = new JPanel();
	JPanel helpPane = new JPanel();
	JPanel buttonPane = new JPanel();
	JButton startButton = new JButton("Spiel starten");
	JButton optionButton = new JButton("Einstellungen");
	JButton helpButton = new JButton("Hilfe");
	JButton exitButton = new JButton("Beenden");
	JButton mainButton = new JButton("Hauptmenü");
	Main() {
		setTitle(" ----- TEST -----");
		setBounds(0,0,800,600);
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		// Button Erreignisse
		startButton.addActionListener(this);
		optionButton.addActionListener(this);
		helpButton.addActionListener(this);
		exitButton.addActionListener(this);
		mainButton.addActionListener(this);
		// Panel für das Hauptmenü
		mainPane.setLayout(new GridLayout(6, 3, 10, 10));
		mainPane.add(new JPanel());
		mainPane.add(new JPanel());
		mainPane.add(new JPanel());
		mainPane.add(new JPanel());
		mainPane.add(startButton);
		mainPane.add(new JPanel());
		mainPane.add(new JPanel());
		mainPane.add(optionButton);
		mainPane.add(new JPanel());
		mainPane.add(new JPanel());
		mainPane.add(helpButton);
		mainPane.add(new JPanel());
		mainPane.add(new JPanel());
		mainPane.add(exitButton);
		mainPane.add(new JPanel());
		mainPane.add(new JPanel());
		mainPane.add(new JPanel());
		mainPane.add(new JPanel());
		buttonPane.setLayout(new BorderLayout(10, 10));
		buttonPane.add(mainButton, BorderLayout.CENTER);
		buttonPane.add(new JPanel(), BorderLayout.WEST);
		buttonPane.add(new JPanel(), BorderLayout.EAST);
		buttonPane.add(new JPanel(), BorderLayout.SOUTH);
		
		c.add(mainPane, BorderLayout.CENTER);
		setVisible(true);
	}
	
	public static void main(String[] arguments) {
		Main main = new Main();
	}
	public void actionPerformed(ActionEvent evt) {
		Object source = evt.getSource();
	
		// Entfernt per Buttonklick das aktuelle Panel und fügt neues hinzu
		if (source == startButton) {
			c.removeAll();
			c.add(level = new LevelElements(this), BorderLayout.CENTER);
			setVisible(true);
			repaint();
		}
		
		if (source == optionButton) {
			c.removeAll();
			c.add(optionPane, BorderLayout.CENTER);
			setVisible(true);
			repaint();
		}
		if (source == helpButton) {
			c.removeAll();
			c.add(helpPane, BorderLayout.CENTER);
			setVisible(true);
			repaint();
		}
		if (source == exitButton) {
			System.exit(0);
		}
		if (source == mainButton) {
			c.removeAll();
			c.add(mainPane, BorderLayout.CENTER);
			setVisible(true);
			repaint();
		}
	}
}