Spiel GUI Anfang
This commit is contained in:
@@ -15,17 +15,26 @@ import javax.swing.ComboBoxModel;
|
|||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Image;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.JComboBox;
|
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{
|
public class Dashboard_GUI extends JPanel{
|
||||||
private static final long serialVersionUID = -7380187913989942586L;
|
private static final long serialVersionUID = -7380187913989942586L;
|
||||||
JPanel panelCont = new JPanel();
|
JPanel panelCont = new JPanel();
|
||||||
JPanel highscore = new JPanel();
|
JPanel highscore = new JPanel();
|
||||||
|
JPanel game = new JPanel();
|
||||||
JPanel start = new JPanel();
|
JPanel start = new JPanel();
|
||||||
Spiel_GUI Spiel_GUI = new Spiel_GUI();
|
|
||||||
JPanel game = Spiel_GUI;
|
|
||||||
CardLayout cl = new CardLayout();
|
CardLayout cl = new CardLayout();
|
||||||
Spielerverwaltung spielerverwaltung = new Spielerverwaltung();
|
Spielerverwaltung spielerverwaltung = new Spielerverwaltung();
|
||||||
private final JPanel panel = new JPanel();
|
private final JPanel panel = new JPanel();
|
||||||
@@ -33,12 +42,86 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
private JComboBox<String> comboBox = new JComboBox<String>();
|
private JComboBox<String> comboBox = new JComboBox<String>();
|
||||||
private final JPanel panel_2 = new JPanel();
|
private final JPanel panel_2 = new JPanel();
|
||||||
private final JLabel lblNewLabel_1 = new JLabel("Entwickler: Sebastian, Moritz, Fabian, Aladin, Elmar");
|
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() {
|
public Dashboard_GUI() {
|
||||||
|
|
||||||
|
|
||||||
setLayout(new BorderLayout(0, 0));
|
setLayout(new BorderLayout(0, 0));
|
||||||
panelCont.setLayout(cl);
|
panelCont.setLayout(cl);
|
||||||
panelCont.add(highscore, "1");
|
panelCont.add(highscore, "1");
|
||||||
panelCont.add(game, "2");
|
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");
|
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));
|
||||||
@@ -57,6 +140,8 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
panel_2.add(lblNewLabel_1);
|
panel_2.add(lblNewLabel_1);
|
||||||
|
|
||||||
highscore.setLayout(new BorderLayout(0, 0));
|
highscore.setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
|
addkarte();
|
||||||
|
|
||||||
cl.show(panelCont, "3");
|
cl.show(panelCont, "3");
|
||||||
add(panelCont);
|
add(panelCont);
|
||||||
@@ -66,7 +151,9 @@ 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();
|
||||||
|
revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showstart(){
|
public void showstart(){
|
||||||
@@ -82,7 +169,6 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
cl.show(panelCont, "1");
|
cl.show(panelCont, "1");
|
||||||
repaint();
|
repaint();
|
||||||
revalidate();
|
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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@ public class GUI extends JFrame{
|
|||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setTitle("JauJau");
|
setTitle("JauJau");
|
||||||
setPreferredSize(new Dimension(800, 500));
|
setPreferredSize(new Dimension(800, 500));
|
||||||
setSize(982, 642);
|
setSize(1565, 916);
|
||||||
getContentPane().setLayout(new BorderLayout(0, 0));
|
getContentPane().setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
JPanel Menue = new JPanel();
|
JPanel Menue = new JPanel();
|
||||||
@@ -113,6 +113,8 @@ public class GUI extends JFrame{
|
|||||||
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();
|
||||||
|
|
||||||
|
//Spiel_GUI Spiel_GUI = new Spiel_GUI();
|
||||||
dashboard.add(Dashboard_GUI, BorderLayout.CENTER);
|
dashboard.add(Dashboard_GUI, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user