GUI Beta Status

This commit is contained in:
ekresse
2021-01-11 16:30:29 +01:00
parent 4b64a40cfe
commit dd760ac35a
5 changed files with 62 additions and 177 deletions

View File

@@ -32,12 +32,12 @@ import javax.swing.JButton;
public class Dashboard_GUI extends JPanel{ public class Dashboard_GUI extends JPanel{
private static final long serialVersionUID = -7380187913989942586L; private static final long serialVersionUID = -7380187913989942586L;
JPanel panelCont = new JPanel(); private JPanel panelCont = new JPanel();
JPanel highscore = new JPanel(); private JPanel highscore = new JPanel();
JPanel game = new JPanel(); private JPanel game = new JPanel();
JPanel start = new JPanel(); private JPanel start = new JPanel();
CardLayout cl = new CardLayout(); private CardLayout cl = new CardLayout();
Spielerverwaltung spielerverwaltung = new Spielerverwaltung(); private Spielerverwaltung spielerverwaltung = new Spielerverwaltung();
private final JPanel panel = new JPanel(); private final JPanel panel = new JPanel();
private final JPanel panel_1 = new JPanel(); private final JPanel panel_1 = new JPanel();
private JComboBox<String> spielername = new JComboBox<String>(); private JComboBox<String> spielername = new JComboBox<String>();
@@ -46,10 +46,10 @@ public class Dashboard_GUI extends JPanel{
private final JPanel spielfeld = new JPanel(); private final JPanel spielfeld = new JPanel();
private final JPanel player_hand = new JPanel(); private final JPanel player_hand = new JPanel();
private final JPanel gegner_hand = new JPanel(); private final JPanel gegner_hand = new JPanel();
JLabel ziehstapel = new JLabel(""); private JLabel ziehstapel = new JLabel("");
JPanel spielerkarten = new JPanel(); private JPanel spielerkarten = new JPanel();
JLabel labelsspieler[] = new JLabel[32]; private JLabel labelsspieler[] = new JLabel[32];
JLabel labelsgegner[] = new JLabel[32]; private JLabel labelsgegner[] = new JLabel[32];
private Spiel aktuellesSpiel; private Spiel aktuellesSpiel;
private JLabel label_aktuellerSpieler; private JLabel label_aktuellerSpieler;
private Texturenpakete texturenpakete; private Texturenpakete texturenpakete;
@@ -57,22 +57,23 @@ public class Dashboard_GUI extends JPanel{
private final JPanel info_panel = new JPanel(); private final JPanel info_panel = new JPanel();
private final JPanel rechts = new JPanel(); private final JPanel rechts = new JPanel();
private final JPanel mitte = new JPanel(); private final JPanel mitte = new JPanel();
JLabel ablagestapel = new JLabel(""); private JLabel ablagestapel = new JLabel("");
JButton aussetzen = new JButton("Aussetzen"); private JButton aussetzen = new JButton("Aussetzen");
JPanel mitte_unten = new JPanel(); private JPanel mitte_unten = new JPanel();
JPanel mitte_center = new JPanel(); private JPanel mitte_center = new JPanel();
private JPanel mitte_oben = new JPanel(); private JPanel mitte_oben = new JPanel();
private JButton btnherz = new JButton("Herz"); private JButton btnherz = new JButton("Herz");
private JButton btnpik = new JButton("Pik"); private JButton btnpik = new JButton("Pik");
private JButton btnkaro = new JButton("Karo"); private JButton btnkaro = new JButton("Karo");
private JButton btnkreuz = new JButton("Kreuz"); private JButton btnkreuz = new JButton("Kreuz");
private final JLabel label_final = new JLabel("Spiel beendet"); private final JLabel label_final = new JLabel("Spiel beendet");
private final JScrollPane gegnerkartenpane = new JScrollPane(); private JScrollPane gegnerkartenpane = new JScrollPane();
private final JPanel gegnerkarten = new JPanel(); private JPanel gegnerkarten = new JPanel();
private final JButton getname = new JButton("setzen"); private JButton getname = new JButton("setzen");
private final JPanel panel_3 = new JPanel(); private JPanel panel_3 = new JPanel();
private final JLabel level_beschreibung = new JLabel("Aktuelles Level:"); private final JLabel level_beschreibung = new JLabel("Aktuelles Level:");
private final JLabel level_count = new JLabel("0"); private JLabel level_count = new JLabel("0");
private final JLabel lblNewLabel_2 = new JLabel("");
//Moving Image //Moving Image
@@ -228,8 +229,11 @@ public class Dashboard_GUI extends JPanel{
mitte.add(mitte_oben, BorderLayout.NORTH); mitte.add(mitte_oben, BorderLayout.NORTH);
mitte_oben.setLayout(new BorderLayout(0, 0)); mitte_oben.setLayout(new BorderLayout(0, 0));
start.setBackground(Color.WHITE);
start.setForeground(Color.WHITE);
panelCont.add(start, "3"); panelCont.add(start, "3");
start.setLayout(new BorderLayout(0, 0)); start.setLayout(new BorderLayout(0, 0));
panel.setBackground(Color.WHITE);
panel.setPreferredSize(new Dimension(10, 30)); panel.setPreferredSize(new Dimension(10, 30));
start.add(panel, BorderLayout.NORTH); start.add(panel, BorderLayout.NORTH);
@@ -246,8 +250,10 @@ public class Dashboard_GUI extends JPanel{
getspielername(); getspielername();
} }
}); });
panel_1.setBackground(Color.WHITE);
start.add(panel_1, BorderLayout.CENTER); start.add(panel_1, BorderLayout.CENTER);
panel_1.setLayout(new BorderLayout(0, 0)); panel_1.setLayout(new BorderLayout(0, 0));
panel_3.setBackground(Color.WHITE);
panel_3.setPreferredSize(new Dimension(100, 50)); panel_3.setPreferredSize(new Dimension(100, 50));
panel_1.add(panel_3, BorderLayout.NORTH); panel_1.add(panel_3, BorderLayout.NORTH);
@@ -259,6 +265,12 @@ public class Dashboard_GUI extends JPanel{
level_count.setFont(new Font("Tahoma", Font.PLAIN, 22)); level_count.setFont(new Font("Tahoma", Font.PLAIN, 22));
panel_3.add(level_count); panel_3.add(level_count);
lblNewLabel_2.setBackground(Color.LIGHT_GRAY);
lblNewLabel_2.setHorizontalTextPosition(SwingConstants.CENTER);
lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_2.setIcon(new ImageIcon(Dashboard_GUI.class.getResource("/img/jaujau.gif")));
panel_1.add(lblNewLabel_2, BorderLayout.CENTER);
start.add(panel_2, BorderLayout.SOUTH); start.add(panel_2, BorderLayout.SOUTH);
@@ -307,7 +319,7 @@ public class Dashboard_GUI extends JPanel{
public void renderStart(){ private void renderStart(){
spielername.removeAllItems(); spielername.removeAllItems();
for(int i = 0; i<spielerverwaltung.gethighscoreTabelle().length; i++) { for(int i = 0; i<spielerverwaltung.gethighscoreTabelle().length; i++) {
spielername.addItem(spielerverwaltung.gethighscoreTabelle()[i][0]); spielername.addItem(spielerverwaltung.gethighscoreTabelle()[i][0]);
@@ -316,7 +328,7 @@ public class Dashboard_GUI extends JPanel{
} }
// Highscore Tabelle // Highscore Tabelle
public void renderHighscore() { private void renderHighscore() {
@@ -342,7 +354,7 @@ public class Dashboard_GUI extends JPanel{
//Spielerhand GUI //Spielerhand GUI
public void aktualisiereHand() { private void aktualisiereHand() {
//Alle Elemente entfernen //Alle Elemente entfernen
for(Component c : spielerkarten.getComponents()){ for(Component c : spielerkarten.getComponents()){
spielerkarten.remove(c); spielerkarten.remove(c);
@@ -381,7 +393,7 @@ public class Dashboard_GUI extends JPanel{
//Gegnerhand GUI //Gegnerhand GUI
public void aktualisiereGegnerHand() { private void aktualisiereGegnerHand() {
//Alle Elemente entfernen //Alle Elemente entfernen
for(Component c : gegnerkarten.getComponents()){ for(Component c : gegnerkarten.getComponents()){
@@ -409,7 +421,7 @@ public class Dashboard_GUI extends JPanel{
// //
public void aktualisiereAblage(){ private void aktualisiereAblage(){
//Sleep oder Wait Funktion zum Verlangsamen der Anzeige //Sleep oder Wait Funktion zum Verlangsamen der Anzeige
@@ -418,7 +430,7 @@ public class Dashboard_GUI extends JPanel{
ablagestapel.repaint(); ablagestapel.repaint();
} }
public void aktualisiereSpieleranzeige() { private void aktualisiereSpieleranzeige() {
if(aktuellesSpiel.getamZug() == Spieler.COMPUTER) { if(aktuellesSpiel.getamZug() == Spieler.COMPUTER) {
label_aktuellerSpieler.setText("Gegner"); label_aktuellerSpieler.setText("Gegner");
label_aktuellerSpieler.setForeground(Color.RED); label_aktuellerSpieler.setForeground(Color.RED);
@@ -435,7 +447,7 @@ public class Dashboard_GUI extends JPanel{
} }
public void aktualisiereZiehen() { private void aktualisiereZiehen() {
for(Component c : rechts.getComponents()){ for(Component c : rechts.getComponents()){
rechts.remove(c); rechts.remove(c);
@@ -493,7 +505,7 @@ public class Dashboard_GUI extends JPanel{
} }
public String getspielername(){ private String getspielername(){
System.out.println("DASHBOARD_GUI: " + spielername.getEditor().getItem()); System.out.println("DASHBOARD_GUI: " + spielername.getEditor().getItem());
return (String) (spielername.getEditor().getItem()); return (String) (spielername.getEditor().getItem());

View File

@@ -9,17 +9,11 @@ import java.awt.Dimension;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import de.jaujau.daten.Spielerverwaltung; import de.jaujau.daten.Spielerverwaltung;
import de.jaujau.daten.Texturenpakete; import de.jaujau.daten.Texturenpakete;
import de.jaujau.spiellogik.Spiel; import de.jaujau.spiellogik.Spiel;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import java.awt.Font; import java.awt.Font;
import java.awt.Toolkit; import java.awt.Toolkit;
@@ -27,12 +21,14 @@ import java.awt.Toolkit;
/** /**
* Class GUI * Klasse GUI
* @author Elmar Kresse
* Diese Klasse gibt das JFrame und die Navigation und kann darüber die einzelnen Dashboard Tabs aufrufen und die Texturenauswahl und Hilfe anzeigen.
*/ */
public class GUI extends JFrame{ public class GUI extends JFrame{
// //
// Fields // Variablen
// //
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private boolean menuehidden = false; private boolean menuehidden = false;
@@ -40,13 +36,13 @@ public class GUI extends JFrame{
private Spiel aktuellesSpiel; private Spiel aktuellesSpiel;
// //
// Constructors // Konstruktor
// //
public GUI (Texturenpakete texturenpakete, Spielerverwaltung speicherung) { public GUI (Texturenpakete texturenpakete, Spielerverwaltung speicherung) {
setIconImage(Toolkit.getDefaultToolkit().getImage(GUI.class.getResource("/img/jaujau.png"))); setIconImage(Toolkit.getDefaultToolkit().getImage(GUI.class.getResource("/img/jaujau.png")));
setMinimumSize(new Dimension(1000, 600)); setMinimumSize(new Dimension(1000, 600));
// jaujau.getAktuellesSpiel(); //JFrame Variablen
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("JauJau"); setTitle("JauJau");
setPreferredSize(new Dimension(800, 500)); setPreferredSize(new Dimension(800, 500));
@@ -119,26 +115,27 @@ public class GUI extends JFrame{
gamelabel.setBounds(0, 91, 220, 29); gamelabel.setBounds(0, 91, 220, 29);
menuhide.add(gamelabel); menuhide.add(gamelabel);
JLabel texturenlabel = new JLabel("Texturen");
//Texturen Label
JLabel texturenlabel = new JLabel("Texturen");
texturenlabel.setHorizontalAlignment(SwingConstants.CENTER); texturenlabel.setHorizontalAlignment(SwingConstants.CENTER);
texturenlabel.setForeground(Color.WHITE); texturenlabel.setForeground(Color.WHITE);
texturenlabel.setFont(new Font("Tahoma", Font.PLAIN, 24)); texturenlabel.setFont(new Font("Tahoma", Font.PLAIN, 24));
texturenlabel.setBounds(0, 131, 220, 29); texturenlabel.setBounds(0, 131, 220, 29);
menuhide.add(texturenlabel); menuhide.add(texturenlabel);
//Dashboard hinzufügen
JPanel dashboard = new JPanel(); JPanel dashboard = new JPanel();
dashboard.setBackground(new Color(73, 128, 242)); dashboard.setBackground(new Color(73, 128, 242));
getContentPane().add(dashboard, BorderLayout.CENTER); getContentPane().add(dashboard, BorderLayout.CENTER);
dashboard.setLayout(new BorderLayout(0, 0)); dashboard.setLayout(new BorderLayout(0, 0));
Dashboard_GUI Dashboard_GUI = new Dashboard_GUI(aktuellesSpiel, texturenpakete); Dashboard_GUI Dashboard_GUI = new Dashboard_GUI(aktuellesSpiel, texturenpakete);
//Spiel_GUI Spiel_GUI = new Spiel_GUI();
dashboard.add(Dashboard_GUI, BorderLayout.CENTER); dashboard.add(Dashboard_GUI, BorderLayout.CENTER);
//Event Listener //Event Listener für die Buttons / Label
//Sidemenue Anzeigen Einklappen
menuebtn.addMouseListener(new MouseAdapter() { menuebtn.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@@ -155,7 +152,7 @@ public class GUI extends JFrame{
} }
}); });
//Hilfe anzeigen/ausblenden
help.addMouseListener(new MouseAdapter() { help.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if(frame.isShowing() == true) { if(frame.isShowing() == true) {
@@ -167,11 +164,11 @@ public class GUI extends JFrame{
} }
}); });
//Spiel starten -- Label zum starten des Spiels
gamelabel.addMouseListener(new MouseAdapter() { gamelabel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
aktuellesSpiel = new Spiel(Dashboard_GUI); aktuellesSpiel = new Spiel(Dashboard_GUI);
System.out.println("GUI: Spiel GUI ge<EFBFBD>ffnet"); System.out.println("GUI: Spiel GUI geöffnet");
Dashboard_GUI.showgame(aktuellesSpiel); Dashboard_GUI.showgame(aktuellesSpiel);
} }
}); });
@@ -180,7 +177,7 @@ public class GUI extends JFrame{
highscorelabel.addMouseListener(new MouseAdapter() { highscorelabel.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
System.out.println("GUI: Highscore ge<EFBFBD>ffnet"); System.out.println("GUI: Highscore geöffnet");
Dashboard_GUI.showhighscore(); Dashboard_GUI.showhighscore();
} }
}); });
@@ -190,7 +187,7 @@ public class GUI extends JFrame{
startlabel.addMouseListener(new MouseAdapter() { startlabel.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
System.out.println("GUI: Start ge<EFBFBD>ffnet"); System.out.println("GUI: Start geöffnet");
Dashboard_GUI.showstart(); Dashboard_GUI.showstart();
} }
}); });
@@ -201,7 +198,7 @@ public class GUI extends JFrame{
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
texturenauswaehlen_GUI texturenauswahl = new texturenauswaehlen_GUI(texturenpakete, speicherung); texturenauswaehlen_GUI texturenauswahl = new texturenauswaehlen_GUI(texturenpakete, speicherung);
System.out.println("GUI: Start ge<EFBFBD>ffnet"); System.out.println("GUI: Start geöffnet");
texturenauswahl.setVisible(true); texturenauswahl.setVisible(true);
} }
}); });

View File

@@ -13,13 +13,15 @@ import javax.swing.JTextArea;
public class Hilfe_GUI extends JFrame { public class Hilfe_GUI extends JFrame {
/** /**
* * Klasse Hilfe_GUI
* @author Elmar Kresse
* Diese Klasse erstelt ein Fenster für die Hilfe
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private JPanel contentPane; private JPanel contentPane;
/** /**
* Create the frame. * Erstelle das JFrame
*/ */
public Hilfe_GUI() { public Hilfe_GUI() {
setAlwaysOnTop(true); setAlwaysOnTop(true);

View File

@@ -1,126 +0,0 @@
package de.jaujau.gui;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Image;
import javax.swing.BoxLayout;
import java.awt.Component;
import javax.swing.ImageIcon;
public class Navigation_GUI
extends JPanel
implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel panel;
// Konstruktor
public Navigation_GUI() {
// Hiermit bekommst du Zugriff auf das <20>bergebene Objekt mainPanel
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
panel = new JPanel();
panel.setBackground(new Color(102, 153, 204));
add(panel);
panel.setLayout(new BorderLayout(0, 0));
JPanel panel_side = new JPanel();
panel_side.setBackground(new Color(100, 149, 237));
panel_side.setPreferredSize(new Dimension(200, 400));
panel.add(panel_side, BorderLayout.CENTER);
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));
JPanel panel = new JPanel();
panel.setBackground(new Color(0, 0, 153));
panel.setPreferredSize(new Dimension(50, 50));
panel_buttons.add(panel, BorderLayout.NORTH);
panel.setLayout(new BorderLayout(0, 0));
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setPreferredSize(new Dimension(50, 50));
lblNewLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
lblNewLabel.setHorizontalTextPosition(SwingConstants.CENTER);
lblNewLabel.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);
JPanel panel_1 = new JPanel();
panel_side.add(panel_1, BorderLayout.CENTER);
JPanel panel_2 = new JPanel();
panel_2.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
}
});
panel_2.setBackground(new Color(0, 102, 204));
JLabel lblNewLabel_1 = new JLabel("Start");
lblNewLabel_1.setBackground(new Color(0, 102, 204));
lblNewLabel_1.setForeground(Color.WHITE);
lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_2.add(lblNewLabel_1);
JLabel label = new JLabel("");
JPanel panel_3 = new JPanel();
panel_3.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
}
});
panel_3.setBackground(new Color(0, 102, 204));
JLabel lblNewLabel_2 = new JLabel("Highscore");
lblNewLabel_2.setForeground(new Color(255, 255, 255));
lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_3.add(lblNewLabel_2);
panel_1.setLayout(new GridLayout(0, 1, 0, 0));
panel_1.add(panel_2);
JLabel label_1 = new JLabel("");
panel_1.add(label_1);
JLabel label_2 = new JLabel("");
panel_1.add(label_2);
panel_1.add(label);
panel_1.add(panel_3);
//Schlie<69>e Button Panel
panel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
panel_1.setVisible(false);
}
});
}
// In dieser Methode <20>nderst du das anzuzeigende Panel
// <20>ber die showPanel-Methode in mainPanel
public void actionPerformed(ActionEvent e) {
}
}

BIN
src/img/jaujau.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB