GUI Update Without Game UI
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
Seb 245
|
||||
Elmo 240
|
||||
Moritz 220
|
||||
Alaa Aldin 217
|
||||
Fabian 215
|
||||
Alaa-Aldin 217
|
||||
Fabian 215
|
||||
Thomas 1233
|
||||
Emil -21331
|
||||
Heinz +312
|
||||
Gert 234
|
||||
Kasper 24
|
||||
Jens 234
|
||||
Paul 234
|
||||
Till 553
|
||||
Reiner 462
|
||||
Achim 2344
|
||||
|
126
src/de/jaujau/gui/Dashboard_GUI.java
Normal file
126
src/de/jaujau/gui/Dashboard_GUI.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package de.jaujau.gui;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Color;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import de.jaujau.daten.Spielerverwaltung;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
|
||||
public class Dashboard_GUI extends JPanel{
|
||||
private static final long serialVersionUID = -7380187913989942586L;
|
||||
JPanel panelCont = new JPanel();
|
||||
JPanel highscore = new JPanel();
|
||||
JPanel start = new JPanel();
|
||||
Spiel_GUI Spiel_GUI = new Spiel_GUI();
|
||||
JPanel game = Spiel_GUI;
|
||||
CardLayout cl = new CardLayout();
|
||||
Spielerverwaltung spielerverwaltung = new Spielerverwaltung();
|
||||
private final JPanel panel = new JPanel();
|
||||
private final JPanel panel_1 = new JPanel();
|
||||
private JComboBox<String> comboBox = new JComboBox<String>();
|
||||
private final JPanel panel_2 = new JPanel();
|
||||
private final JLabel lblNewLabel_1 = new JLabel("Entwickler: Sebastian, Moritz, Fabian, Aladin, Elmar");
|
||||
|
||||
public Dashboard_GUI() {
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
panelCont.setLayout(cl);
|
||||
panelCont.add(highscore, "1");
|
||||
panelCont.add(game, "2");
|
||||
panelCont.add(start, "3");
|
||||
start.setLayout(new BorderLayout(0, 0));
|
||||
panel.setPreferredSize(new Dimension(10, 30));
|
||||
|
||||
start.add(panel, BorderLayout.NORTH);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("Spielername:");
|
||||
panel.add(lblNewLabel);
|
||||
comboBox.setMinimumSize(new Dimension(60, 22));
|
||||
comboBox.setEditable(true);
|
||||
panel.add(comboBox);
|
||||
start.add(panel_1, BorderLayout.CENTER);
|
||||
|
||||
start.add(panel_2, BorderLayout.SOUTH);
|
||||
|
||||
panel_2.add(lblNewLabel_1);
|
||||
|
||||
highscore.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
cl.show(panelCont, "3");
|
||||
add(panelCont);
|
||||
renderStart(); //Startseite beim ersten <20>ffnen aktualisieren
|
||||
}
|
||||
|
||||
|
||||
public void showgame(){
|
||||
System.out.println("DASHBOARD: Game darstellen");
|
||||
cl.show(panelCont, "2");
|
||||
}
|
||||
|
||||
public void showstart(){
|
||||
System.out.println("DASHBOARD: Start darstellen");
|
||||
cl.show(panelCont, "3");
|
||||
renderStart();
|
||||
}
|
||||
|
||||
|
||||
public void showhighscore(){
|
||||
System.out.println("DASHBOARD: Highscore darstellen");
|
||||
renderHighscore();
|
||||
cl.show(panelCont, "1");
|
||||
repaint();
|
||||
revalidate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void renderStart(){
|
||||
comboBox.removeAllItems();
|
||||
for(int i = 0; i<spielerverwaltung.gethighscoreTabelle().length; i++) {
|
||||
comboBox.addItem(spielerverwaltung.gethighscoreTabelle()[i][0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Highscore Tabelle
|
||||
public void renderHighscore() {
|
||||
|
||||
|
||||
|
||||
String[][] rowData = spielerverwaltung.gethighscoreTabelle(); //Bsp. Datensatz muss noch entfernt werden.
|
||||
|
||||
String[] columnNames = {"Name", "Punkte"};
|
||||
highscore.setLayout(new BorderLayout(0, 0));
|
||||
JTable table = new JTable(); //Leere Tabelle
|
||||
DefaultTableModel tableModel = new DefaultTableModel(rowData, columnNames) { //Tabelle formatieren und Zellen nicht bearbeitbar machen
|
||||
private static final long serialVersionUID = 838285314713L;
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
//all cells false
|
||||
return false;
|
||||
}
|
||||
};
|
||||
table.setAutoCreateRowSorter(true); //Tabelle Sortierbar durch Tabellenkopf
|
||||
table.getTableHeader().setReorderingAllowed(false); //Tabelle nicht mehr drag and drop
|
||||
table.setModel(tableModel);
|
||||
|
||||
|
||||
highscore.add( new JScrollPane( table ) );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,19 +3,17 @@ package de.jaujau.gui;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import de.jaujau.daten.Spielerverwaltung;
|
||||
import de.jaujau.daten.Texturenpakete;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.SwingConstants;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.FlowLayout;
|
||||
import javax.swing.BoxLayout;
|
||||
import java.awt.Font;
|
||||
|
||||
|
||||
|
||||
@@ -28,20 +26,20 @@ public class GUI extends JFrame{
|
||||
// Fields
|
||||
//
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Spielerverwaltung spielerverwaltung;
|
||||
private boolean menuehidden = false;
|
||||
Hilfe_GUI frame = new Hilfe_GUI();
|
||||
private JPanel panel2;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public GUI (Spielerverwaltung speicherung) {
|
||||
public GUI () {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setTitle("JauJau");
|
||||
setPreferredSize(new Dimension(800, 500));
|
||||
setSize(982, 642);
|
||||
this.spielerverwaltung = speicherung;
|
||||
getContentPane().setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel Menue = new JPanel();
|
||||
@@ -82,17 +80,46 @@ public class GUI extends JFrame{
|
||||
menuhide.setPreferredSize(new Dimension(220, 200));
|
||||
menuhide.setBackground(new Color(25, 29, 74));
|
||||
Menue.add(menuhide);
|
||||
menuhide.setLayout(new BorderLayout(0, 0));
|
||||
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);
|
||||
|
||||
JPanel dashboard = new JPanel();
|
||||
dashboard.setBackground(new Color(73, 128, 242));
|
||||
getContentPane().add(dashboard, BorderLayout.CENTER);
|
||||
dashboard.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
Spiel_GUI Spiel_GUI = new Spiel_GUI();
|
||||
dashboard.add(Spiel_GUI);
|
||||
Dashboard_GUI Dashboard_GUI = new Dashboard_GUI();
|
||||
dashboard.add(Dashboard_GUI, BorderLayout.CENTER);
|
||||
|
||||
|
||||
|
||||
|
||||
//Event Listener
|
||||
|
||||
menuebtn.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@@ -121,11 +148,37 @@ public class GUI extends JFrame{
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
gamelabel.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
System.out.println("GUI: Spiel GUI ge<67>ffnet");
|
||||
Dashboard_GUI.showgame();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
highscorelabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
System.out.println("GUI: Highscore ge<67>ffnet");
|
||||
Dashboard_GUI.showhighscore();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
startlabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
System.out.println("GUI: Start ge<67>ffnet");
|
||||
Dashboard_GUI.showstart();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,119 +0,0 @@
|
||||
package de.jaujau.gui;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
|
||||
import de.jaujau.daten.Spielerverwaltung;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import java.awt.Font;
|
||||
|
||||
|
||||
public class Menue_GUI
|
||||
extends JPanel {
|
||||
|
||||
private CardLayout cardLayout;
|
||||
|
||||
private JPanel panel1, panel2, panel3;
|
||||
private int sizemenu = 270;
|
||||
|
||||
|
||||
// Konstruktor
|
||||
public Menue_GUI(Spielerverwaltung speicherung) {
|
||||
|
||||
setBorder(javax.swing.BorderFactory.createTitledBorder("Content"));
|
||||
|
||||
cardLayout = new CardLayout();
|
||||
|
||||
this.setLayout(cardLayout);
|
||||
|
||||
// Objekte der Panel erzeugen, die angezeigt werden sollen
|
||||
panel1 = new JPanel();
|
||||
panel1.setName("panel1");
|
||||
panel2 = new JPanel();
|
||||
panel2.setName("panel2");
|
||||
panel3 = new JPanel();
|
||||
panel3.setName("panel3");
|
||||
|
||||
panel1.setBackground(Color.YELLOW);
|
||||
panel2.setBackground(Color.WHITE);
|
||||
panel3.setBackground(Color.GREEN);
|
||||
|
||||
JLabel label1 = new JLabel("Startseite");
|
||||
label1.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
JLabel label2 = new JLabel("Highscore");
|
||||
label2.setFont(new Font("Tahoma", Font.PLAIN, 18));
|
||||
label2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
|
||||
|
||||
renderHighscore(); //Highscore Tabelle wird geladen
|
||||
panel2.setVisible( true );
|
||||
|
||||
|
||||
|
||||
JLabel label3 = new JLabel("Panel 3: Spiel");
|
||||
panel2.add(label2, BorderLayout.NORTH);
|
||||
panel3.add(label3);
|
||||
|
||||
this.add(panel1, "Start");
|
||||
panel1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
||||
panel1.add(label1);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("New label");
|
||||
panel1.add(lblNewLabel_1);
|
||||
this.add(panel2, "Highscore");
|
||||
this.add(panel3, "Spiel");
|
||||
|
||||
JPanel panel4 = new JPanel();
|
||||
panel4.setBackground(Color.LIGHT_GRAY);
|
||||
this.add(panel4, "Einstellungen");
|
||||
|
||||
JLabel lblNewLabel = new JLabel("Einstellungen");
|
||||
panel4.add(lblNewLabel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void showPanel(String panel) {
|
||||
|
||||
cardLayout.show(this, panel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void renderHighscore() {
|
||||
|
||||
String[][] rowData = {{ "Seb", "245" }, { "Elmo", "240" }, { "Moritz","220" }, { "Alaa Aldin", "217" }, {"Fabian", "215"}}; //Bsp. Datensatz muss noch entfernt werden.
|
||||
|
||||
String[] columnNames = {"Name", "Punkte"};
|
||||
panel2.setLayout(new BorderLayout(0, 0));
|
||||
JTable table = new JTable(); //Leere Tabelle
|
||||
DefaultTableModel tableModel = new DefaultTableModel(rowData, columnNames) { //Tabelle formatieren und Zellen nicht bearbeitbar machen
|
||||
private static final long serialVersionUID = 838285314713L;
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
//all cells false
|
||||
return false;
|
||||
}
|
||||
};
|
||||
table.setAutoCreateRowSorter(true); //Tabelle Sortierbar durch Tabellenkopf
|
||||
table.getTableHeader().setReorderingAllowed(false); //Tabelle nicht mehr drag and drop
|
||||
table.setModel(tableModel);
|
||||
|
||||
|
||||
panel2.add( new JScrollPane( table ) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -34,11 +34,10 @@ public class Navigation_GUI
|
||||
extends JPanel
|
||||
implements ActionListener {
|
||||
private JPanel panel;
|
||||
private Menue_GUI Menue_GUI;
|
||||
|
||||
|
||||
// Konstruktor
|
||||
public Navigation_GUI(Menue_GUI menue_GUI) {
|
||||
this.Menue_GUI = menue_GUI;
|
||||
public Navigation_GUI() {
|
||||
|
||||
// Hiermit bekommst du Zugriff auf das <20>bergebene Objekt mainPanel
|
||||
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
||||
@@ -84,7 +83,6 @@ implements ActionListener {
|
||||
panel_2.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
Menue_GUI.showPanel("Start");
|
||||
}
|
||||
});
|
||||
panel_2.setBackground(new Color(0, 102, 204));
|
||||
@@ -101,7 +99,6 @@ implements ActionListener {
|
||||
panel_3.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
Menue_GUI.showPanel("Highscore");
|
||||
}
|
||||
});
|
||||
panel_3.setBackground(new Color(0, 102, 204));
|
||||
@@ -134,15 +131,5 @@ implements ActionListener {
|
||||
// In dieser Methode <20>nderst du das anzuzeigende Panel
|
||||
// <20>ber die showPanel-Methode in mainPanel
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
|
||||
if(e.getActionCommand().equals("Highscore"))
|
||||
Menue_GUI.showPanel("Highscore");
|
||||
|
||||
if(e.getActionCommand().equals("Spiel"))
|
||||
Menue_GUI.showPanel("Spiel");
|
||||
|
||||
if(e.getActionCommand().equals("Einstellungen"))
|
||||
Menue_GUI.showPanel("Einstellungen");
|
||||
}
|
||||
}
|
@@ -13,6 +13,8 @@ import de.jaujau.daten.Texturenpakete;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.JSlider;
|
||||
|
||||
public class Spiel_GUI extends JPanel implements ActionListener {
|
||||
|
||||
@@ -28,7 +30,14 @@ public class Spiel_GUI extends JPanel implements ActionListener {
|
||||
*/
|
||||
public Spiel_GUI() {
|
||||
setLayout(null);
|
||||
System.out.println("Spiel_GUI: Spiel-GUI aufgerufen");
|
||||
|
||||
JToggleButton tglbtnNewToggleButton = new JToggleButton("New toggle button");
|
||||
tglbtnNewToggleButton.setBounds(365, 244, 121, 23);
|
||||
add(tglbtnNewToggleButton);
|
||||
|
||||
JSlider slider = new JSlider();
|
||||
slider.setBounds(215, 412, 200, 26);
|
||||
add(slider);
|
||||
initialize(spielerverwaltung);
|
||||
}
|
||||
/**
|
||||
@@ -58,7 +67,7 @@ public class Spiel_GUI extends JPanel implements ActionListener {
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
g.drawImage(texturen.getTextur(31), 50, 50, null);
|
||||
//g.drawImage(texturen.getTextur(31), 50, 50, null);
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user