GUI Upgrade

This commit is contained in:
ekresse
2020-12-03 12:57:04 +01:00
parent 52c2f969b8
commit 5816595d10
2 changed files with 140 additions and 27 deletions

View File

@@ -13,7 +13,7 @@ public class Spielerverwaltung {
//
private int level;
private String name;
private String name = "Mark Zuckerberg"; //Testeintrag
/**
* arraylist von Spieler
*/
@@ -55,6 +55,7 @@ public class Spielerverwaltung {
* @return the value of level
*/
public String getName () {
return name;
}

View File

@@ -16,6 +16,7 @@ import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import de.jaujau.daten.Spielerverwaltung;
@@ -30,14 +31,15 @@ import java.net.URL;
import java.awt.Component;
import java.awt.Font;
public class Menue_GUI extends JFrame implements ActionListener {
public class Menue_GUI extends GUI implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private Spielerverwaltung spielerverwaltung;
private JFrame frame;
private JPanel contentPane;
private boolean shown = true;
@@ -49,7 +51,7 @@ public class Menue_GUI extends JFrame implements ActionListener {
this.spielerverwaltung = speicherung;
speicherung.getSpieler();
System.out.println("Men<EFBFBD>-GUI aufgerufen");
initialize();
initialize(this.spielerverwaltung);
}
/**
@@ -58,17 +60,17 @@ public class Menue_GUI extends JFrame implements ActionListener {
//Test GUI f<>r JauJau
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 783, 762);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new BorderLayout(0, 0));
frame.setVisible(true);
private void initialize(Spielerverwaltung speicherung) {
this.spielerverwaltung = speicherung;
setBounds(100, 100, 963, 762);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(new BorderLayout(0, 0));
setVisible(true);
JPanel panel_top = new JPanel();
panel_top.setPreferredSize(new Dimension(200, 100));
panel_top.setBackground(new Color(0, 0, 128));
frame.getContentPane().add(panel_top, BorderLayout.NORTH);
this.getContentPane().add(panel_top, BorderLayout.NORTH);
panel_top.setLayout(new BorderLayout(0, 0));
JLabel lblNewLabel_1 = new JLabel("JauJau");
@@ -81,42 +83,153 @@ public class Menue_GUI extends JFrame implements ActionListener {
panel_top.add(lblNewLabel_1, BorderLayout.CENTER);
JPanel panel_side = new JPanel();
panel_side.setBackground(new Color(100, 149, 237));
panel_side.setPreferredSize(new Dimension(200, 400));
frame.getContentPane().add(panel_side, BorderLayout.WEST);
panel_side.setBackground(new Color(0, 51, 153));
panel_side.setPreferredSize(new Dimension(270, 400));
this.getContentPane().add(panel_side, BorderLayout.WEST);
panel_side.setLayout(new BorderLayout(0, 0));
JPanel panel_buttons = new JPanel();
panel_buttons.setBackground(new Color(0, 0, 128));
panel_buttons.setPreferredSize(new Dimension(50, 200));
panel_side.add(panel_buttons, BorderLayout.WEST);
panel_buttons.setLayout(new BorderLayout(0, 0));
panel_buttons.setLayout(null);
JPanel panel = new JPanel();
panel.setBounds(0, 0, 50, 50);
panel.setBackground(new Color(0, 0, 153));
panel.setPreferredSize(new Dimension(50, 50));
panel_buttons.add(panel, BorderLayout.NORTH);
panel_buttons.add(panel);
panel.setLayout(new BorderLayout(0, 0));
JLabel lblNewLabel = new JLabel("");
lblNewLabel.addMouseListener(new MouseAdapter() {
JLabel minimize = new JLabel("");
minimize.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
panel_side.setVisible(false);
if(shown == true) {
panel_side.setPreferredSize(new Dimension(50, panel_side.getHeight()));
System.out.println("Update GUI 50");
panel_side.revalidate();
panel_side.repaint();
shown = false;
}else{
panel_side.setPreferredSize(new Dimension(270, panel_side.getHeight()));
System.out.println("Update GUI 270");
panel_side.revalidate();
panel_side.repaint();
shown = true;
}
}
});
lblNewLabel.setPreferredSize(new Dimension(50, 50));
lblNewLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
lblNewLabel.setHorizontalTextPosition(SwingConstants.CENTER);
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
minimize.setPreferredSize(new Dimension(50, 50));
minimize.setAlignmentX(Component.CENTER_ALIGNMENT);
minimize.setHorizontalTextPosition(SwingConstants.CENTER);
minimize.setHorizontalAlignment(SwingConstants.CENTER);
ImageIcon imageIcon = new ImageIcon(new ImageIcon("C:\\Users\\Elmar\\Pictures\\exit.png").getImage().getScaledInstance(40, 40, Image.SCALE_DEFAULT));
lblNewLabel.setIcon(imageIcon);
panel.add(lblNewLabel, BorderLayout.CENTER);
minimize.setIcon(imageIcon);
panel.add(minimize, BorderLayout.CENTER);
JPanel buttons = new JPanel();
buttons.setBackground(new Color(51, 51, 153));
panel_side.add(buttons, BorderLayout.CENTER);
buttons.setLayout(new BorderLayout(0, 0));
JPanel panel_4 = new JPanel();
panel_4.setBackground(new Color(0, 51, 153));
buttons.add(panel_4, BorderLayout.CENTER);
panel_4.setLayout(null);
JLabel start = new JLabel("Spiel starten");
start.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
//Spiel starten Spiel_GUI und schlie<69>e Menue_GUI (wechsel) und Spiellogikaufrufen
System.out.println("Start Game");
}
});
start.setBackground(Color.WHITE);
start.setForeground(Color.WHITE);
start.setFont(new Font("Segoe UI", Font.PLAIN, 26));
start.setHorizontalAlignment(SwingConstants.CENTER);
start.setAlignmentX(Component.CENTER_ALIGNMENT);
start.setBounds(0, 0, 220, 31);
panel_4.add(start);
JLabel score = new JLabel("Highscore");
score.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
//Rechtes Panel <20>ndern und Highscore aus jaujaudaten abrufen.
System.out.println("Highscore");
}
});
score.setBackground(Color.WHITE);
score.setForeground(Color.WHITE);
score.setFont(new Font("Segoe UI", Font.PLAIN, 26));
score.setHorizontalAlignment(SwingConstants.CENTER);
score.setAlignmentX(Component.CENTER_ALIGNMENT);
score.setBounds(0, 42, 220, 31);
panel_4.add(score);
JLabel settings = new JLabel("Einstellungen");
settings.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
//Rechtes Panel <20>ndern und Einstellungen aufrufen
System.out.println("Highscore");
}
});
settings.setBackground(Color.WHITE);
settings.setForeground(Color.WHITE);
settings.setFont(new Font("Segoe UI", Font.PLAIN, 26));
settings.setHorizontalAlignment(SwingConstants.CENTER);
settings.setAlignmentX(Component.CENTER_ALIGNMENT);
settings.setBounds(0, 84, 220, 31);
panel_4.add(settings);
JLabel help = new JLabel("Hilfe");
help.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
//Starte Hilfe GUI Menue_GUI bleibt ge<67>ffnet
System.out.println("Hilfe");
}
});
help.setBackground(Color.WHITE);
help.setForeground(Color.WHITE);
help.setFont(new Font("Segoe UI", Font.PLAIN, 26));
help.setHorizontalAlignment(SwingConstants.CENTER);
help.setAlignmentX(Component.CENTER_ALIGNMENT);
help.setBounds(0, 126, 220, 31);
panel_4.add(help);
JPanel panel_main = new JPanel();
panel_main.setPreferredSize(new Dimension(600, 600));
frame.getContentPane().add(panel_main, BorderLayout.CENTER);
this.getContentPane().add(panel_main, BorderLayout.CENTER);
panel_main.setLayout(new BoxLayout(panel_main, BoxLayout.X_AXIS));
JPanel panel_1 = new JPanel();
panel_1.setBackground(new Color(102, 153, 255));
panel_main.add(panel_1);
panel_1.setLayout(new BorderLayout(0, 0));
JPanel panel_2 = new JPanel();
panel_2.setBackground(new Color(51, 153, 204));
panel_1.add(panel_2, BorderLayout.CENTER);
panel_2.setLayout(new BorderLayout(0, 0));
JLabel lblNewLabel_2 = new JLabel("Name: ");
lblNewLabel_2.setForeground(Color.WHITE);
lblNewLabel_2.setFont(new Font("Segoe UI", Font.PLAIN, 26));
lblNewLabel_2.setBackground(new Color(51, 153, 204));
panel_2.add(lblNewLabel_2, BorderLayout.NORTH);
lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_2.setVerticalAlignment(SwingConstants.TOP);
lblNewLabel_2.setText("Name: " + speicherung.getName());
JPanel panel_3 = new JPanel();
panel_3.setBackground(new Color(51, 153, 204));
panel_2.add(panel_3, BorderLayout.CENTER);
}
@Override
@@ -124,5 +237,4 @@ public class Menue_GUI extends JFrame implements ActionListener {
// TODO Auto-generated method stub
}
}