Anwendungs und GUI Test
This commit is contained in:
@@ -7,7 +7,12 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
|
import de.jaujau.daten.Audio;
|
||||||
|
import de.jaujau.daten.Spieler;
|
||||||
import de.jaujau.daten.Spielerverwaltung;
|
import de.jaujau.daten.Spielerverwaltung;
|
||||||
|
import de.jaujau.spiellogik.Anwendung;
|
||||||
|
import de.jaujau.spiellogik.Spiel;
|
||||||
|
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
@@ -28,6 +33,8 @@ import java.awt.Component;
|
|||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.ComponentOrientation;
|
import java.awt.ComponentOrientation;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
public class Dashboard_GUI extends JPanel{
|
public class Dashboard_GUI extends JPanel{
|
||||||
private static final long serialVersionUID = -7380187913989942586L;
|
private static final long serialVersionUID = -7380187913989942586L;
|
||||||
@@ -52,10 +59,9 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
private final JLabel lblNewLabel_2_1 = new JLabel("");
|
private final JLabel lblNewLabel_2_1 = new JLabel("");
|
||||||
JPanel imagepanel = new JPanel();
|
JPanel imagepanel = new JPanel();
|
||||||
JLabel labels[] = new JLabel[32];
|
JLabel labels[] = new JLabel[32];
|
||||||
|
private Audio sound = new Audio();
|
||||||
|
|
||||||
|
public Dashboard_GUI(Spiel aktuellesSpiel) {
|
||||||
|
|
||||||
public Dashboard_GUI() {
|
|
||||||
|
|
||||||
|
|
||||||
setLayout(new BorderLayout(0, 0));
|
setLayout(new BorderLayout(0, 0));
|
||||||
@@ -81,29 +87,6 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
imagepanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
imagepanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
||||||
|
|
||||||
|
|
||||||
//1. Label
|
|
||||||
JLabel lblNewLabel_2 = new JLabel("");
|
|
||||||
lblNewLabel_2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
|
||||||
lblNewLabel_2.setAlignmentY(Component.TOP_ALIGNMENT);
|
|
||||||
lblNewLabel_2.setBounds(new Rectangle(0, 0, 120, 180));
|
|
||||||
lblNewLabel_2.setSize(new Dimension(120, 180));
|
|
||||||
lblNewLabel_2.setHorizontalTextPosition(SwingConstants.CENTER);
|
|
||||||
lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
|
|
||||||
lblNewLabel_2.setIcon(new ImageIcon(new javax.swing.ImageIcon(getClass().getResource("/img/texturen/standart/12.png")).getImage().getScaledInstance(lblNewLabel_2.getWidth(), lblNewLabel_2.getHeight(), Image.SCALE_SMOOTH)));
|
|
||||||
imagepanel.add(lblNewLabel_2);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 2. Label
|
|
||||||
lblNewLabel_2_1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
|
||||||
lblNewLabel_2_1.setSize(new Dimension(120, 180));
|
|
||||||
lblNewLabel_2_1.setHorizontalTextPosition(SwingConstants.CENTER);
|
|
||||||
lblNewLabel_2_1.setHorizontalAlignment(SwingConstants.CENTER);
|
|
||||||
lblNewLabel_2_1.setBounds(new Rectangle(0, 0, 120, 180));
|
|
||||||
lblNewLabel_2_1.setAlignmentY(0.0f);
|
|
||||||
lblNewLabel_2_1.setIcon(new ImageIcon(new javax.swing.ImageIcon(getClass().getResource("/img/texturen/standart/3.png")).getImage().getScaledInstance(lblNewLabel_2.getWidth(), lblNewLabel_2.getHeight(), Image.SCALE_SMOOTH)));
|
|
||||||
imagepanel.add(lblNewLabel_2_1);
|
|
||||||
|
|
||||||
gegner_hand.setBounds(0, 0, 1269, 152);
|
gegner_hand.setBounds(0, 0, 1269, 152);
|
||||||
|
|
||||||
spielfeld.add(gegner_hand);
|
spielfeld.add(gegner_hand);
|
||||||
@@ -122,6 +105,16 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
|
|
||||||
|
|
||||||
spielfeld.add(ziehstapel);
|
spielfeld.add(ziehstapel);
|
||||||
|
|
||||||
|
JButton btnNewButton_1 = new JButton("Audio");
|
||||||
|
btnNewButton_1.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
sound.test();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
btnNewButton_1.setBounds(293, 346, 89, 23);
|
||||||
|
spielfeld.add(btnNewButton_1);
|
||||||
panelCont.add(start, "3");
|
panelCont.add(start, "3");
|
||||||
start.setLayout(new BorderLayout(0, 0));
|
start.setLayout(new BorderLayout(0, 0));
|
||||||
panel.setPreferredSize(new Dimension(10, 30));
|
panel.setPreferredSize(new Dimension(10, 30));
|
||||||
@@ -141,7 +134,15 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
|
|
||||||
highscore.setLayout(new BorderLayout(0, 0));
|
highscore.setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
addkarte();
|
|
||||||
|
|
||||||
|
aktuellesSpiel.getKartensatz().ziehen(Spieler.SPIELER);
|
||||||
|
aktuellesSpiel.getKartensatz().ziehen(Spieler.SPIELER);
|
||||||
|
aktuellesSpiel.getKartensatz().ziehen(Spieler.SPIELER);
|
||||||
|
aktuellesSpiel.getKartensatz().ziehen(Spieler.SPIELER);
|
||||||
|
aktuellesSpiel.getKartensatz().ziehen(Spieler.SPIELER);
|
||||||
|
aktuellesSpiel.getKartensatz().ziehen(Spieler.SPIELER);
|
||||||
|
aktualisiereHand(aktuellesSpiel);
|
||||||
|
|
||||||
cl.show(panelCont, "3");
|
cl.show(panelCont, "3");
|
||||||
add(panelCont);
|
add(panelCont);
|
||||||
@@ -151,7 +152,8 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
|
|
||||||
public void showgame(){
|
public void showgame(){
|
||||||
System.out.println("DASHBOARD: Game darstellen");
|
System.out.println("DASHBOARD: Game darstellen");
|
||||||
cl.show(panelCont, "2");
|
cl.show(panelCont, "2");
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
revalidate();
|
revalidate();
|
||||||
}
|
}
|
||||||
@@ -208,22 +210,29 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addkarte() {
|
void aktualisiereHand(Spiel aktuellesSpiel) {
|
||||||
int i = 4;
|
|
||||||
labels[i] = new JLabel();
|
|
||||||
String path = "/img/texturen/standart/12.png";
|
|
||||||
|
|
||||||
labels[i].setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
for(int i = 0; i< aktuellesSpiel.getKartensatz().getHand(Spieler.SPIELER).size(); i++){
|
||||||
labels[i].setAlignmentY(Component.TOP_ALIGNMENT);
|
|
||||||
labels[i].setBounds(new Rectangle(0, 0, 120, 180));
|
labels[i] = new JLabel();
|
||||||
labels[i].setSize(new Dimension(120, 180));
|
String path = "/img/texturen/standart/" + Integer.toString(aktuellesSpiel.getKartensatz().getHand(Spieler.SPIELER).get(i)) + ".png";
|
||||||
labels[i].setHorizontalTextPosition(SwingConstants.CENTER);
|
labels[i].setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
labels[i].setHorizontalAlignment(SwingConstants.CENTER);
|
labels[i].setAlignmentY(Component.TOP_ALIGNMENT);
|
||||||
labels[i].setIcon(new ImageIcon(new javax.swing.ImageIcon(getClass().getResource(path)).getImage().getScaledInstance(labels[i].getWidth(), labels[i].getHeight(), Image.SCALE_SMOOTH)));
|
labels[i].setBounds(new Rectangle(0, 0, 120, 180));
|
||||||
imagepanel.add(labels[4]);
|
labels[i].setSize(new Dimension(120, 180));
|
||||||
imagepanel.updateUI(); //Panel erneuern
|
labels[i].setHorizontalTextPosition(SwingConstants.CENTER);
|
||||||
|
labels[i].setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
labels[i].setIcon(new ImageIcon(new javax.swing.ImageIcon(getClass().getResource(path)).getImage().getScaledInstance(labels[i].getWidth(), labels[i].getHeight(), Image.SCALE_SMOOTH)));
|
||||||
|
imagepanel.add(labels[i]);
|
||||||
|
imagepanel.updateUI(); //Panel erneuern
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -10,6 +10,12 @@ 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.Texturenpakete;
|
||||||
|
import de.jaujau.spiellogik.Anwendung;
|
||||||
|
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 javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
@@ -28,15 +34,16 @@ public class GUI extends JFrame{
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private boolean menuehidden = false;
|
private boolean menuehidden = false;
|
||||||
Hilfe_GUI frame = new Hilfe_GUI();
|
Hilfe_GUI frame = new Hilfe_GUI();
|
||||||
private JPanel panel2;
|
private Spiel aktuellesSpiel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructors
|
// Constructors
|
||||||
//
|
//
|
||||||
public GUI () {
|
public GUI (Texturenpakete texturenpakete, Spielerverwaltung speicherung) {
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
|
aktuellesSpiel = new Spiel();
|
||||||
|
// jaujau.getAktuellesSpiel();
|
||||||
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setTitle("JauJau");
|
setTitle("JauJau");
|
||||||
setPreferredSize(new Dimension(800, 500));
|
setPreferredSize(new Dimension(800, 500));
|
||||||
setSize(1565, 916);
|
setSize(1565, 916);
|
||||||
@@ -112,7 +119,7 @@ public class GUI extends JFrame{
|
|||||||
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();
|
Dashboard_GUI Dashboard_GUI = new Dashboard_GUI(aktuellesSpiel);
|
||||||
|
|
||||||
//Spiel_GUI Spiel_GUI = new Spiel_GUI();
|
//Spiel_GUI Spiel_GUI = new Spiel_GUI();
|
||||||
dashboard.add(Dashboard_GUI, BorderLayout.CENTER);
|
dashboard.add(Dashboard_GUI, BorderLayout.CENTER);
|
||||||
@@ -153,6 +160,7 @@ public class GUI extends JFrame{
|
|||||||
|
|
||||||
gamelabel.addMouseListener(new MouseAdapter() {
|
gamelabel.addMouseListener(new MouseAdapter() {
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
aktuellesSpiel = new Spiel();
|
||||||
System.out.println("GUI: Spiel GUI ge<67>ffnet");
|
System.out.println("GUI: Spiel GUI ge<67>ffnet");
|
||||||
Dashboard_GUI.showgame();
|
Dashboard_GUI.showgame();
|
||||||
}
|
}
|
||||||
|
@@ -15,97 +15,29 @@ import de.jaujau.gui.GUI;
|
|||||||
|
|
||||||
public class Anwendung {
|
public class Anwendung {
|
||||||
|
|
||||||
private Spiel aktuellesSpiel;
|
|
||||||
private Texturenpakete texturenpakete;
|
private Texturenpakete texturenpakete;
|
||||||
private Spielerverwaltung speicherung;
|
private Spielerverwaltung speicherung;
|
||||||
private GUI gui;
|
private GUI view;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructors
|
// Constructors
|
||||||
//
|
//
|
||||||
public Anwendung() {
|
public Anwendung() {
|
||||||
|
speicherung = new Spielerverwaltung();
|
||||||
speicherung = new Spielerverwaltung();
|
texturenpakete = new Texturenpakete();
|
||||||
gui = new GUI();
|
view = new GUI(texturenpakete, speicherung);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
//
|
|
||||||
// Methods
|
|
||||||
|
|
||||||
//
|
|
||||||
// Accessor methods
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
* Set the value of aktuellesSpiel
|
|
||||||
*
|
|
||||||
* @param newVar the new value of aktuellesSpiel
|
|
||||||
*/
|
|
||||||
public void setAktuellesSpiel(Spiel newSpiel) {
|
|
||||||
aktuellesSpiel = newSpiel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the value of aktuellesSpiel
|
|
||||||
*
|
|
||||||
* @return the value of aktuellesSpiel
|
|
||||||
*/
|
|
||||||
public Spiel getAktuellesSpiel() {
|
|
||||||
return aktuellesSpiel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value of texturenpakete
|
|
||||||
*
|
|
||||||
* @param newVar the new value of texturenpakete
|
|
||||||
*/
|
|
||||||
public void setTexturenpakete(Texturenpakete newTexture) {
|
|
||||||
texturenpakete = newTexture;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the value of texturenpakete
|
|
||||||
*
|
|
||||||
* @return the value of texturenpakete
|
|
||||||
*/
|
|
||||||
public Texturenpakete getTexturenpakete() {
|
|
||||||
return texturenpakete;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value of speicherung
|
|
||||||
*
|
|
||||||
* @param newVar the new value of speicherung
|
|
||||||
*/
|
|
||||||
public void setSpeicherung(Spielerverwaltung newVer) {
|
|
||||||
speicherung = newVer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the value of speicherung
|
|
||||||
*
|
|
||||||
* @return the value of speicherung
|
|
||||||
*/
|
|
||||||
public Spielerverwaltung getSpeicherung() {
|
|
||||||
return speicherung;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Other methods
|
|
||||||
//
|
|
||||||
public static void openMenue_GUI(Anwendung jaujau) { // Menue_GUI oeffnen!
|
|
||||||
jaujau.gui.setVisible(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Anwendung jaujau = new Anwendung();
|
/**
|
||||||
openMenue_GUI(jaujau);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launch the application.
|
* Launch the application.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Anwendung jaujau = new Anwendung();
|
||||||
|
jaujau.view.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user