Spiel GUI Anfang

This commit is contained in:
ekresse
2021-01-06 10:45:36 +01:00
parent 24ad891263
commit 521a145c4e
3 changed files with 111 additions and 80 deletions

View File

@@ -15,17 +15,26 @@ import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import javax.swing.ImageIcon;
import javax.swing.DebugGraphics;
import java.awt.Rectangle;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.ComponentOrientation;
import java.awt.Cursor;
public class Dashboard_GUI extends JPanel{
private static final long serialVersionUID = -7380187913989942586L;
JPanel panelCont = new JPanel();
JPanel highscore = new JPanel();
JPanel game = 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();
@@ -33,12 +42,86 @@ public class Dashboard_GUI extends 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");
private final JButton btnNewButton = new JButton("New button");
private final JPanel spielfeld = new JPanel();
private final JPanel player_hand = new JPanel();
private final JPanel gegner_hand = new JPanel();
private final JLabel ablagestapel = new JLabel("Ablagestapel");
private final JLabel ziehstapel = new JLabel("");
private final JScrollPane scrollPane = new JScrollPane();
private final JLabel lblNewLabel_2_1 = new JLabel("");
JPanel imagepanel = new JPanel();
JLabel labels[] = new JLabel[32];
public Dashboard_GUI() {
setLayout(new BorderLayout(0, 0));
panelCont.setLayout(cl);
panelCont.add(highscore, "1");
panelCont.add(game, "2");
game.setLayout(new BorderLayout(0, 0));
game.add(spielfeld, BorderLayout.CENTER);
spielfeld.setLayout(null);
player_hand.setBounds(0, 660, 1269, 212);
spielfeld.add(player_hand);
player_hand.setLayout(new BorderLayout(0, 0));
JScrollPane scrollPane_1 = new JScrollPane();
player_hand.add(scrollPane_1, BorderLayout.CENTER);
imagepanel.setAutoscrolls(true);
imagepanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
scrollPane_1.setViewportView(imagepanel);
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);
gegner_hand.setLayout(new BorderLayout(0, 0));
gegner_hand.add(scrollPane);
ablagestapel.setHorizontalAlignment(SwingConstants.CENTER);
ablagestapel.setBounds(618, 267, 137, 210);
spielfeld.add(ablagestapel);
ziehstapel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
ziehstapel.setPreferredSize(new Dimension(242, 362));
ziehstapel.setHorizontalAlignment(SwingConstants.CENTER);
ziehstapel.setBounds(1093, 267, 137, 210);
ziehstapel.setIcon(new ImageIcon(new javax.swing.ImageIcon(getClass().getResource("/img/texturen/standart/32.png")).getImage().getScaledInstance(ziehstapel.getWidth(), ziehstapel.getHeight(), Image.SCALE_SMOOTH)));
spielfeld.add(ziehstapel);
panelCont.add(start, "3");
start.setLayout(new BorderLayout(0, 0));
panel.setPreferredSize(new Dimension(10, 30));
@@ -58,6 +141,8 @@ public class Dashboard_GUI extends JPanel{
highscore.setLayout(new BorderLayout(0, 0));
addkarte();
cl.show(panelCont, "3");
add(panelCont);
renderStart(); //Startseite beim ersten <20>ffnen aktualisieren
@@ -67,6 +152,8 @@ public class Dashboard_GUI extends JPanel{
public void showgame(){
System.out.println("DASHBOARD: Game darstellen");
cl.show(panelCont, "2");
repaint();
revalidate();
}
public void showstart(){
@@ -82,7 +169,6 @@ public class Dashboard_GUI extends JPanel{
cl.show(panelCont, "1");
repaint();
revalidate();
}
@@ -121,6 +207,23 @@ public class Dashboard_GUI extends JPanel{
}
void addkarte() {
int i = 4;
labels[i] = new JLabel();
String path = "/img/texturen/standart/12.png";
labels[i].setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
labels[i].setAlignmentY(Component.TOP_ALIGNMENT);
labels[i].setBounds(new Rectangle(0, 0, 120, 180));
labels[i].setSize(new Dimension(120, 180));
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.updateUI(); //Panel erneuern
}
}

View File

@@ -39,7 +39,7 @@ public class GUI extends JFrame{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("JauJau");
setPreferredSize(new Dimension(800, 500));
setSize(982, 642);
setSize(1565, 916);
getContentPane().setLayout(new BorderLayout(0, 0));
JPanel Menue = new JPanel();
@@ -113,6 +113,8 @@ public class GUI extends JFrame{
dashboard.setLayout(new BorderLayout(0, 0));
Dashboard_GUI Dashboard_GUI = new Dashboard_GUI();
//Spiel_GUI Spiel_GUI = new Spiel_GUI();
dashboard.add(Dashboard_GUI, BorderLayout.CENTER);

View File

@@ -1,74 +0,0 @@
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 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;
import javax.swing.JToggleButton;
import javax.swing.JSlider;
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);
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);
}
/**
* 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));
texturen.addPaket("StandartTexturenBeta3.zip");
texturen.setAktivesPaket(0);
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
public void paint(Graphics g) {
//g.drawImage(texturen.getTextur(31), 50, 50, null);
}
}