204 lines
5.6 KiB
Java
204 lines
5.6 KiB
Java
package de.jaujau.gui;
|
|
|
|
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JPanel;
|
|
import java.awt.BorderLayout;
|
|
import java.awt.Color;
|
|
import java.awt.Dimension;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.SwingConstants;
|
|
|
|
import de.jaujau.daten.Spielerverwaltung;
|
|
import de.jaujau.daten.Texturenpakete;
|
|
import de.jaujau.spiellogik.Spiel;
|
|
|
|
import java.awt.event.MouseAdapter;
|
|
import java.awt.event.MouseEvent;
|
|
import javax.swing.BoxLayout;
|
|
import java.awt.Font;
|
|
|
|
|
|
|
|
/**
|
|
* Class GUI
|
|
*/
|
|
public class GUI extends JFrame{
|
|
|
|
//
|
|
// Fields
|
|
//
|
|
private static final long serialVersionUID = 1L;
|
|
private boolean menuehidden = false;
|
|
Hilfe_GUI frame = new Hilfe_GUI();
|
|
private Spiel aktuellesSpiel;
|
|
|
|
//
|
|
// Constructors
|
|
//
|
|
public GUI (Texturenpakete texturenpakete, Spielerverwaltung speicherung) {
|
|
setMinimumSize(new Dimension(1000, 600));
|
|
|
|
|
|
// jaujau.getAktuellesSpiel();
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
setTitle("JauJau");
|
|
setPreferredSize(new Dimension(800, 500));
|
|
setSize(1565, 916);
|
|
getContentPane().setLayout(new BorderLayout(0, 0));
|
|
|
|
JPanel Menue = new JPanel();
|
|
Menue.setPreferredSize(new Dimension(270, 450));
|
|
getContentPane().add(Menue, BorderLayout.WEST);
|
|
Menue.setLayout(new BoxLayout(Menue, BoxLayout.X_AXIS));
|
|
|
|
JPanel MenueIcon = new JPanel();
|
|
MenueIcon.setPreferredSize(new Dimension(50, 450));
|
|
MenueIcon.setBackground(new Color(15, 19, 52));
|
|
Menue.add(MenueIcon);
|
|
MenueIcon.setLayout(null);
|
|
|
|
JPanel help = new JPanel();
|
|
help.setBounds(0, 0, 50, 50);
|
|
help.setBackground(new Color(15, 19, 52));
|
|
MenueIcon.add(help);
|
|
|
|
JLabel helplable = new JLabel("");
|
|
helplable.setHorizontalTextPosition(SwingConstants.CENTER);
|
|
helplable.setHorizontalAlignment(SwingConstants.CENTER);
|
|
helplable.setIcon(new ImageIcon(GUI.class.getResource("/img/help.png")));
|
|
help.add(helplable);
|
|
|
|
JPanel menuebtn = new JPanel();
|
|
menuebtn.setBounds(0, 50, 50, 50);
|
|
MenueIcon.add(menuebtn);
|
|
menuebtn.setLayout(new BorderLayout(0, 0));
|
|
|
|
JLabel menuelabel = new JLabel("");
|
|
menuelabel.setHorizontalTextPosition(SwingConstants.CENTER);
|
|
menuelabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
menuelabel.setIcon(new ImageIcon(GUI.class.getResource("/img/menue.png")));
|
|
menuebtn.add(menuelabel);
|
|
menuebtn.setBackground(new Color(15, 19, 52));
|
|
|
|
JPanel menuhide = new JPanel();
|
|
menuhide.setPreferredSize(new Dimension(220, 200));
|
|
menuhide.setBackground(new Color(25, 29, 74));
|
|
Menue.add(menuhide);
|
|
menuhide.setLayout(null);
|
|
|
|
JLabel startlabel = new JLabel("Startseite");
|
|
|
|
startlabel.setBounds(0, 11, 220, 29);
|
|
startlabel.setVerticalAlignment(SwingConstants.TOP);
|
|
startlabel.setForeground(Color.WHITE);
|
|
startlabel.setFont(new Font("Tahoma", Font.PLAIN, 24));
|
|
startlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
menuhide.add(startlabel);
|
|
|
|
JLabel highscorelabel = new JLabel("Highscore");
|
|
|
|
highscorelabel.setBounds(0, 51, 220, 29);
|
|
highscorelabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
highscorelabel.setForeground(Color.WHITE);
|
|
highscorelabel.setFont(new Font("Tahoma", Font.PLAIN, 24));
|
|
menuhide.add(highscorelabel);
|
|
|
|
JLabel gamelabel = new JLabel("Spielen");
|
|
|
|
gamelabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
gamelabel.setForeground(Color.WHITE);
|
|
gamelabel.setFont(new Font("Tahoma", Font.PLAIN, 24));
|
|
gamelabel.setBounds(0, 91, 220, 29);
|
|
menuhide.add(gamelabel);
|
|
|
|
JLabel texturenlabel = new JLabel("Texturen");
|
|
|
|
texturenlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
texturenlabel.setForeground(Color.WHITE);
|
|
texturenlabel.setFont(new Font("Tahoma", Font.PLAIN, 24));
|
|
texturenlabel.setBounds(0, 131, 220, 29);
|
|
menuhide.add(texturenlabel);
|
|
|
|
JPanel dashboard = new JPanel();
|
|
dashboard.setBackground(new Color(73, 128, 242));
|
|
getContentPane().add(dashboard, BorderLayout.CENTER);
|
|
dashboard.setLayout(new BorderLayout(0, 0));
|
|
|
|
Dashboard_GUI Dashboard_GUI = new Dashboard_GUI(aktuellesSpiel, texturenpakete);
|
|
|
|
//Spiel_GUI Spiel_GUI = new Spiel_GUI();
|
|
dashboard.add(Dashboard_GUI, BorderLayout.CENTER);
|
|
|
|
//Event Listener
|
|
|
|
menuebtn.addMouseListener(new MouseAdapter() {
|
|
@Override
|
|
public void mouseClicked(MouseEvent e) {
|
|
if(menuehidden == true) {
|
|
menuhide.setVisible(false);
|
|
Menue.setPreferredSize(new Dimension(50, Menue.getHeight()));
|
|
menuehidden = false;
|
|
}else{
|
|
menuhide.setVisible(true);
|
|
Menue.setPreferredSize(new Dimension(270, Menue.getHeight()));
|
|
menuehidden = true;
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
|
|
help.addMouseListener(new MouseAdapter() {
|
|
public void mouseClicked(MouseEvent e) {
|
|
if(frame.isShowing() == true) {
|
|
frame.setVisible(false);
|
|
}else{
|
|
frame.setVisible(true);
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
|
|
gamelabel.addMouseListener(new MouseAdapter() {
|
|
public void mouseClicked(MouseEvent e) {
|
|
aktuellesSpiel = new Spiel(Dashboard_GUI);
|
|
System.out.println("GUI: Spiel GUI geöffnet");
|
|
Dashboard_GUI.showgame(aktuellesSpiel);
|
|
}
|
|
});
|
|
|
|
|
|
highscorelabel.addMouseListener(new MouseAdapter() {
|
|
@Override
|
|
public void mouseClicked(MouseEvent e) {
|
|
System.out.println("GUI: Highscore geöffnet");
|
|
Dashboard_GUI.showhighscore();
|
|
}
|
|
});
|
|
|
|
|
|
|
|
startlabel.addMouseListener(new MouseAdapter() {
|
|
@Override
|
|
public void mouseClicked(MouseEvent e) {
|
|
System.out.println("GUI: Start geöffnet");
|
|
Dashboard_GUI.showstart();
|
|
}
|
|
});
|
|
|
|
|
|
|
|
texturenlabel.addMouseListener(new MouseAdapter() {
|
|
@Override
|
|
public void mouseClicked(MouseEvent e) {
|
|
texturenauswaehlen_GUI texturenauswahl = new texturenauswaehlen_GUI(texturenpakete);
|
|
texturenauswahl.setVisible(true);
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|