Anwendungs und GUI Test
This commit is contained in:
@@ -7,7 +7,12 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import de.jaujau.daten.Audio;
|
||||
import de.jaujau.daten.Spieler;
|
||||
import de.jaujau.daten.Spielerverwaltung;
|
||||
import de.jaujau.spiellogik.Anwendung;
|
||||
import de.jaujau.spiellogik.Spiel;
|
||||
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.BoxLayout;
|
||||
@@ -28,6 +33,8 @@ import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.ComponentOrientation;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Dashboard_GUI extends JPanel{
|
||||
private static final long serialVersionUID = -7380187913989942586L;
|
||||
@@ -52,10 +59,9 @@ public class Dashboard_GUI extends JPanel{
|
||||
private final JLabel lblNewLabel_2_1 = new JLabel("");
|
||||
JPanel imagepanel = new JPanel();
|
||||
JLabel labels[] = new JLabel[32];
|
||||
private Audio sound = new Audio();
|
||||
|
||||
|
||||
|
||||
public Dashboard_GUI() {
|
||||
public Dashboard_GUI(Spiel aktuellesSpiel) {
|
||||
|
||||
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
@@ -81,29 +87,6 @@ public class Dashboard_GUI extends JPanel{
|
||||
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);
|
||||
|
||||
spielfeld.add(gegner_hand);
|
||||
@@ -122,6 +105,16 @@ public class Dashboard_GUI extends JPanel{
|
||||
|
||||
|
||||
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");
|
||||
start.setLayout(new BorderLayout(0, 0));
|
||||
panel.setPreferredSize(new Dimension(10, 30));
|
||||
@@ -141,7 +134,15 @@ public class Dashboard_GUI extends JPanel{
|
||||
|
||||
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");
|
||||
add(panelCont);
|
||||
@@ -152,6 +153,7 @@ public class Dashboard_GUI extends JPanel{
|
||||
public void showgame(){
|
||||
System.out.println("DASHBOARD: Game darstellen");
|
||||
cl.show(panelCont, "2");
|
||||
|
||||
repaint();
|
||||
revalidate();
|
||||
}
|
||||
@@ -208,11 +210,12 @@ public class Dashboard_GUI extends JPanel{
|
||||
|
||||
}
|
||||
|
||||
void addkarte() {
|
||||
int i = 4;
|
||||
labels[i] = new JLabel();
|
||||
String path = "/img/texturen/standart/12.png";
|
||||
void aktualisiereHand(Spiel aktuellesSpiel) {
|
||||
|
||||
for(int i = 0; i< aktuellesSpiel.getKartensatz().getHand(Spieler.SPIELER).size(); i++){
|
||||
|
||||
labels[i] = new JLabel();
|
||||
String path = "/img/texturen/standart/" + Integer.toString(aktuellesSpiel.getKartensatz().getHand(Spieler.SPIELER).get(i)) + ".png";
|
||||
labels[i].setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
labels[i].setAlignmentY(Component.TOP_ALIGNMENT);
|
||||
labels[i].setBounds(new Rectangle(0, 0, 120, 180));
|
||||
@@ -220,10 +223,16 @@ public class Dashboard_GUI extends JPanel{
|
||||
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[4]);
|
||||
imagepanel.add(labels[i]);
|
||||
imagepanel.updateUI(); //Panel erneuern
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -10,6 +10,12 @@ import java.awt.Dimension;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.ImageIcon;
|
||||
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.MouseEvent;
|
||||
import javax.swing.BoxLayout;
|
||||
@@ -28,14 +34,15 @@ public class GUI extends JFrame{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean menuehidden = false;
|
||||
Hilfe_GUI frame = new Hilfe_GUI();
|
||||
private JPanel panel2;
|
||||
|
||||
|
||||
private Spiel aktuellesSpiel;
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public GUI () {
|
||||
public GUI (Texturenpakete texturenpakete, Spielerverwaltung speicherung) {
|
||||
|
||||
aktuellesSpiel = new Spiel();
|
||||
// jaujau.getAktuellesSpiel();
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setTitle("JauJau");
|
||||
setPreferredSize(new Dimension(800, 500));
|
||||
@@ -112,7 +119,7 @@ public class GUI extends JFrame{
|
||||
getContentPane().add(dashboard, BorderLayout.CENTER);
|
||||
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();
|
||||
dashboard.add(Dashboard_GUI, BorderLayout.CENTER);
|
||||
@@ -153,6 +160,7 @@ public class GUI extends JFrame{
|
||||
|
||||
gamelabel.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
aktuellesSpiel = new Spiel();
|
||||
System.out.println("GUI: Spiel GUI ge<67>ffnet");
|
||||
Dashboard_GUI.showgame();
|
||||
}
|
||||
|
@@ -15,97 +15,29 @@ import de.jaujau.gui.GUI;
|
||||
|
||||
public class Anwendung {
|
||||
|
||||
private Spiel aktuellesSpiel;
|
||||
private Texturenpakete texturenpakete;
|
||||
private Spielerverwaltung speicherung;
|
||||
private GUI gui;
|
||||
private GUI view;
|
||||
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public Anwendung() {
|
||||
|
||||
speicherung = new Spielerverwaltung();
|
||||
gui = new GUI();
|
||||
texturenpakete = new Texturenpakete();
|
||||
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) {
|
||||
Anwendung jaujau = new Anwendung();
|
||||
openMenue_GUI(jaujau);
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
|
||||
Anwendung jaujau = new Anwendung();
|
||||
jaujau.view.setVisible(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user