Merge branch 'patch-1' of https://gitlab.imn.htwk-leipzig.de/weicker/inb1-a-jaujau.git into patch-1
This commit is contained in:
@@ -1,45 +1,131 @@
|
||||
package de.jaujau.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
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.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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Class GUI
|
||||
*/
|
||||
public class GUI extends JFrame implements ActionListener{
|
||||
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();
|
||||
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public GUI () { }
|
||||
public GUI (Spielerverwaltung speicherung) {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setTitle("JauJau");
|
||||
setPreferredSize(new Dimension(800, 500));
|
||||
setSize(982, 642);
|
||||
this.spielerverwaltung = speicherung;
|
||||
getContentPane().setLayout(new BorderLayout(0, 0));
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
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(new BorderLayout(0, 0));
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Accessor methods
|
||||
//
|
||||
|
||||
//
|
||||
// Other methods
|
||||
//
|
||||
|
||||
}
|
||||
|
@@ -1,34 +1,43 @@
|
||||
package de.jaujau.gui;
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingConstants;
|
||||
import java.awt.Font;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
/**
|
||||
* Class Hilfe_GUI
|
||||
*/
|
||||
public class Hilfe_GUI {
|
||||
public class Hilfe_GUI extends JFrame {
|
||||
|
||||
//
|
||||
// Fields
|
||||
//
|
||||
private JPanel contentPane;
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Hilfe_GUI() {
|
||||
setBounds(100, 100, 588, 382);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
contentPane.setLayout(new BorderLayout(0, 0));
|
||||
setContentPane(contentPane);
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public Hilfe_GUI () { };
|
||||
JLabel lblNewLabel = new JLabel("Hilfe");
|
||||
lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 20));
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
contentPane.add(lblNewLabel, BorderLayout.NORTH);
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
contentPane.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
|
||||
//
|
||||
// Accessor methods
|
||||
//
|
||||
|
||||
//
|
||||
// Other methods
|
||||
//
|
||||
JTextArea txtrJaujauJaujauIst = new JTextArea();
|
||||
txtrJaujauJaujauIst.setEditable(false);
|
||||
txtrJaujauJaujauIst.setText("JauJau\r\nJauJau ist ein Java basiertes Spiel was nach auf dem Spielprinzip von MauMau aufbaut.\r\n\r\nProduktvision\r\nJauJau - \"Java-MauMau\" Interaktives Spieldesign, welches die traditionellen\r\nSpielmechaniken von MauMau digitalisiert und es m\u00F6glich macht auch alleine den\r\nbeliebten Klassiker zu spielen. Individuell - durch Spielerfolg Freischaltung\r\nneuer Kartendesigns.\r\n\r\nSpielidee\r\n\r\nKartenspiel auf Basis von MauMau.\r\nEin Spieler spielt gegen eine Computer Spieler\r\nDie Punktest\u00E4nde der Spieler werden Gespeichert\r\nMit h\u00F6heren Punktestand werden zus\u00E4tzliche Kartentexturenpakete freigeschaltete\r\n\r\n\r\nSpielregeln\r\nAkionskarten:\r\n\r\n7 - zwei ziehen\r\n8 - Aussetzen\r\nBube - W\u00FCnscher\r\n\r\nZusatzregeln:\r\n\r\n9 - Richtungswechsel\r\n8 - Stopper hebt Aktionskarte 7 \"zwei ziehen\" auf\r\n10 - Allesleger (darf auf jede Karte gelegt werden)\r\n\r\n\r\nFeatures\r\n\r\nAutomatischer \"Jau\" Ausruf bei letzter Karte und \"JauJau\" beim Ablegen der letzten\r\nverschiedene Texturenpackete f\u00FCr Kartens\u00E4tze\r\n\r\n\r\nAnforderungen\r\n\r\nKompatibel mit verschieden Betriebssystemen\r\nSkalierung der GUI\r\nJava 11 Support");
|
||||
scrollPane.setViewportView(txtrJaujauJaujauIst);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,240 +1,119 @@
|
||||
package de.jaujau.gui;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Image;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JButton;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.JPanel;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.Icon;
|
||||
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
|
||||
import de.jaujau.daten.Spielerverwaltung;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
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 GUI implements ActionListener {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Spielerverwaltung spielerverwaltung;
|
||||
private JPanel contentPane;
|
||||
private boolean shown = true;
|
||||
public class Menue_GUI
|
||||
extends JPanel {
|
||||
|
||||
private CardLayout cardLayout;
|
||||
|
||||
private JPanel panel1, panel2, panel3;
|
||||
private int sizemenu = 270;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create the application.
|
||||
* @param speicherung
|
||||
*/
|
||||
// Konstruktor
|
||||
public Menue_GUI(Spielerverwaltung speicherung) {
|
||||
this.spielerverwaltung = speicherung;
|
||||
speicherung.getSpieler();
|
||||
System.out.println("Men<EFBFBD>-GUI aufgerufen");
|
||||
initialize(this.spielerverwaltung);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
/**
|
||||
* Initialize the contents of the frame.
|
||||
*/
|
||||
|
||||
//Test GUI f<>r JauJau
|
||||
|
||||
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));
|
||||
this.getContentPane().add(panel_top, BorderLayout.NORTH);
|
||||
panel_top.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("JauJau");
|
||||
lblNewLabel_1.setForeground(Color.WHITE);
|
||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1.setInheritsPopupMenu(false);
|
||||
lblNewLabel_1.setIgnoreRepaint(false);
|
||||
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 40));
|
||||
lblNewLabel_1.setVerticalAlignment(SwingConstants.CENTER);
|
||||
panel_top.add(lblNewLabel_1, BorderLayout.CENTER);
|
||||
|
||||
JPanel panel_side = new JPanel();
|
||||
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(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);
|
||||
panel.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
|
||||
JLabel minimize = new JLabel("");
|
||||
minimize.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
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));
|
||||
minimize.setIcon(imageIcon);
|
||||
panel.add(minimize, BorderLayout.CENTER);
|
||||
public void showPanel(String panel) {
|
||||
|
||||
JPanel buttons = new JPanel();
|
||||
buttons.setBackground(new Color(51, 51, 153));
|
||||
panel_side.add(buttons, BorderLayout.CENTER);
|
||||
buttons.setLayout(new BorderLayout(0, 0));
|
||||
cardLayout.show(this, panel);
|
||||
|
||||
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);
|
||||
public void renderHighscore() {
|
||||
|
||||
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);
|
||||
String[][] rowData = {{ "Seb", "245" }, { "Elmo", "240" }, { "Moritz","220" }, { "Alaa Aldin", "217" }, {"Fabian", "215"}}; //Bsp. Datensatz muss noch entfernt werden.
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
JPanel panel_main = new JPanel();
|
||||
panel_main.setPreferredSize(new Dimension(600, 600));
|
||||
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));
|
||||
panel2.add( new JScrollPane( table ) );
|
||||
|
||||
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
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
148
src/de/jaujau/gui/Navigation_GUI.java
Normal file
148
src/de/jaujau/gui/Navigation_GUI.java
Normal file
@@ -0,0 +1,148 @@
|
||||
package de.jaujau.gui;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.JButton;
|
||||
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.Image;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import java.awt.Component;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.Insets;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
// 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) {
|
||||
Menue_GUI.showPanel("Start");
|
||||
}
|
||||
});
|
||||
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) {
|
||||
Menue_GUI.showPanel("Highscore");
|
||||
}
|
||||
});
|
||||
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) {
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
@@ -1,34 +1,65 @@
|
||||
package de.jaujau.gui;
|
||||
import java.awt.Image;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.BoxLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import java.util.*;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import de.jaujau.daten.Kartensatz;
|
||||
import de.jaujau.daten.Spielerverwaltung;
|
||||
import de.jaujau.daten.Texturenpakete;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class Spiel_GUI extends JPanel implements ActionListener {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Spielerverwaltung spielerverwaltung;
|
||||
Texturenpakete texturen = new Texturenpakete();
|
||||
/**
|
||||
* Create the application.
|
||||
* @param speicherung
|
||||
*/
|
||||
public Spiel_GUI() {
|
||||
setLayout(null);
|
||||
System.out.println("Spiel_GUI: Spiel-GUI aufgerufen");
|
||||
initialize(spielerverwaltung);
|
||||
}
|
||||
/**
|
||||
* Initialize the contents of the frame.
|
||||
*/
|
||||
|
||||
//Test GUI f<>r JauJau
|
||||
|
||||
private void initialize(Spielerverwaltung speicherung) {
|
||||
this.spielerverwaltung = speicherung;
|
||||
setBounds(100, 100, 963, 762);
|
||||
JPanel panel_main = new JPanel();
|
||||
panel_main.setPreferredSize(new Dimension(600, 600));;
|
||||
panel_main.setLayout(new BoxLayout(panel_main, BoxLayout.X_AXIS));
|
||||
|
||||
|
||||
/**
|
||||
* Class Spiel_GUI
|
||||
*/
|
||||
public class Spiel_GUI {
|
||||
|
||||
//
|
||||
// Fields
|
||||
//
|
||||
texturen.addPaket("C:\\Users\\Elmar\\Downloads\\StandartTexturenBeta2.zip");
|
||||
texturen.setAktivesPaket(0);
|
||||
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public Spiel_GUI () { };
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Accessor methods
|
||||
//
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
//
|
||||
// Other methods
|
||||
//
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
g.drawImage(texturen.getTextur(31), 50, 50, null);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import de.jaujau.daten.Spielerverwaltung;
|
||||
import de.jaujau.daten.Texturenpakete;
|
||||
import de.jaujau.gui.GUI;
|
||||
import de.jaujau.gui.Menue_GUI;
|
||||
import de.jaujau.gui.Spiel_GUI;
|
||||
|
||||
|
||||
public class Anwendung {
|
||||
@@ -11,15 +12,14 @@ public class Anwendung {
|
||||
private Spiel aktuellesSpiel;
|
||||
private Texturenpakete texturenpakete;
|
||||
private Spielerverwaltung speicherung;
|
||||
private static Menue_GUI gui;
|
||||
|
||||
private GUI gui;
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public Anwendung() {
|
||||
|
||||
speicherung = new Spielerverwaltung();
|
||||
gui = new Menue_GUI(speicherung);
|
||||
gui = new GUI(speicherung);
|
||||
|
||||
};
|
||||
//
|
||||
@@ -82,51 +82,23 @@ public class Anwendung {
|
||||
return speicherung;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of gui
|
||||
*
|
||||
* @param newVar the new value of gui
|
||||
*/
|
||||
public static void setGui(Menue_GUI newVar) {
|
||||
gui = newVar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of gui
|
||||
* @return the value of gui
|
||||
*/
|
||||
public static GUI getGui () {
|
||||
return gui;
|
||||
}
|
||||
|
||||
//
|
||||
// Other methods
|
||||
//
|
||||
public static void openGui() { // GUI oeffnen!
|
||||
Anwendung jaujau = new Anwendung();
|
||||
jaujau.gui.setVisible(true);
|
||||
public static void openMenue_GUI(Anwendung jaujau) { //Menue_GUI oeffnen!
|
||||
jaujau.gui.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static void main(String[] args){
|
||||
openGui();
|
||||
|
||||
//
|
||||
// Other methods
|
||||
//
|
||||
Anwendung jaujau = new Anwendung();
|
||||
openMenue_GUI(jaujau);
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
|
||||
/*public static void main(String[] args)
|
||||
{
|
||||
System.out.println("Programm gestartet");
|
||||
Anwendung jaujau = new Anwendung();
|
||||
jaujau.gui.setVisible(true);
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
BIN
src/img/exit.png
Normal file
BIN
src/img/exit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 505 B |
BIN
src/img/help.png
Normal file
BIN
src/img/help.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 357 B |
BIN
src/img/max.png
Normal file
BIN
src/img/max.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
src/img/menue.png
Normal file
BIN
src/img/menue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 696 B |
BIN
src/img/min.png
Normal file
BIN
src/img/min.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 360 B |
Reference in New Issue
Block a user