Compare commits
No commits in common. "88d016ed9986062df023062f22e67b0afc31e17c" and "1fc1abee3a4708ffaef6ca08635f99e3db67fad6" have entirely different histories.
88d016ed99
...
1fc1abee3a
|
@ -1,8 +1,10 @@
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class JoinGame extends JPanel {
|
public class JoinGame extends JPanel {
|
||||||
JLabel spielBeitretenLabel;
|
JLabel spielBeitretenLabel= new JLabel("Spiel beitreten");
|
||||||
JLabel ipLabel = new JLabel("IP-Adresse");
|
JLabel ipLabel = new JLabel("IP-Adresse");
|
||||||
JLabel portLabel = new JLabel("Port");
|
JLabel portLabel = new JLabel("Port");
|
||||||
|
|
||||||
|
@ -13,18 +15,12 @@ public class JoinGame extends JPanel {
|
||||||
|
|
||||||
Font robotoFont = new Font("Roboto", Font.BOLD, 45);
|
Font robotoFont = new Font("Roboto", Font.BOLD, 45);
|
||||||
|
|
||||||
public JoinGame(MainFrame frame,int g) {
|
public JoinGame(MainFrame frame) {
|
||||||
setLayout(null);
|
setLayout(null);
|
||||||
buildPanel(frame,g);
|
buildPanel(frame);
|
||||||
}
|
|
||||||
|
|
||||||
private void buildPanel(MainFrame frame,int g) {
|
|
||||||
if(g==1){
|
|
||||||
spielBeitretenLabel= new JLabel("Spiel beitreten");
|
|
||||||
}else{
|
|
||||||
spielBeitretenLabel= new JLabel("Spiel erstellen");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buildPanel(MainFrame frame) {
|
||||||
spielBeitretenLabel.setBounds(20,20,700, 100);
|
spielBeitretenLabel.setBounds(20,20,700, 100);
|
||||||
losButton.setBounds(320, 225, 100, 50);
|
losButton.setBounds(320, 225, 100, 50);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ public class MainFrame extends JFrame {
|
||||||
|
|
||||||
private CardLayout cardLayout;
|
private CardLayout cardLayout;
|
||||||
private JPanel mainPanel;
|
private JPanel mainPanel;
|
||||||
int localMult;
|
|
||||||
|
|
||||||
public MainFrame() {
|
public MainFrame() {
|
||||||
setTitle("Studium Versenken");
|
setTitle("Studium Versenken");
|
||||||
|
@ -28,13 +27,13 @@ public class MainFrame extends JFrame {
|
||||||
startLocalGame localGame = new startLocalGame(this);
|
startLocalGame localGame = new startLocalGame(this);
|
||||||
startMultiplayerGame multiplayerGame = new startMultiplayerGame(this);
|
startMultiplayerGame multiplayerGame = new startMultiplayerGame(this);
|
||||||
coinToss coinToss = new coinToss(this);
|
coinToss coinToss = new coinToss(this);
|
||||||
//JoinGame joinGame = new JoinGame(this,localMult);
|
JoinGame joinGame = new JoinGame(this);
|
||||||
|
|
||||||
mainPanel.add(mainMenuView, "MainMenu");
|
mainPanel.add(mainMenuView, "MainMenu");
|
||||||
mainPanel.add(localGame, "LocalGame");
|
mainPanel.add(localGame, "LocalGame");
|
||||||
mainPanel.add(multiplayerGame, "MultiplayerGame");
|
mainPanel.add(multiplayerGame, "MultiplayerGame");
|
||||||
mainPanel.add(coinToss, "coinToss");
|
mainPanel.add(coinToss, "coinToss");
|
||||||
//mainPanel.add(joinGame, "JoinGame");
|
mainPanel.add(joinGame, "JoinGame");
|
||||||
// Hauptpanel in JFrame hinzufügen
|
// Hauptpanel in JFrame hinzufügen
|
||||||
add(mainPanel);
|
add(mainPanel);
|
||||||
|
|
||||||
|
@ -47,27 +46,6 @@ public class MainFrame extends JFrame {
|
||||||
cardLayout.show(mainPanel, panelName);
|
cardLayout.show(mainPanel, panelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showPanelExtra(String panelName,int num) {
|
|
||||||
this.localMult = num;
|
|
||||||
|
|
||||||
if (!isPanelPresent(panelName)) {
|
|
||||||
JoinGame joinGame = new JoinGame(this, localMult);
|
|
||||||
mainPanel.add(joinGame, panelName); // Dynamically add the panel
|
|
||||||
mainPanel.revalidate(); // Refresh the layout
|
|
||||||
mainPanel.repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
cardLayout.show(mainPanel, panelName); // Show the panel
|
|
||||||
}
|
|
||||||
private boolean isPanelPresent(String panelName) {
|
|
||||||
for (Component component : mainPanel.getComponents()) {
|
|
||||||
if (panelName.equals(mainPanel.getClientProperty("name"))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
MainFrame frame = new MainFrame();
|
MainFrame frame = new MainFrame();
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
public class startMultiplayerGame extends JPanel {
|
public class startMultiplayerGame extends JPanel {
|
||||||
// Funktionshilfen
|
// Funktionshilfen
|
||||||
int semesterCounter = 1; // Semester Counter Label
|
int semesterCounter = 1; // Semester Counter Label
|
||||||
String PlayerNickname = "Spieler 1";
|
String PlayerNickname = "Spieler 1";
|
||||||
|
|
||||||
// Grafiken
|
// Grafiken
|
||||||
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
ImageIcon backButtonIcon = new ImageIcon("graphics/backButton.png");
|
||||||
ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
||||||
|
@ -106,8 +109,7 @@ public class startMultiplayerGame extends JPanel {
|
||||||
// ActionListener für den "Back" Button, um zum vorherigen Panel zurückzukehren
|
// ActionListener für den "Back" Button, um zum vorherigen Panel zurückzukehren
|
||||||
|
|
||||||
backButton.addActionListener(e -> frame.showPanel("MainMenu"));
|
backButton.addActionListener(e -> frame.showPanel("MainMenu"));
|
||||||
joinGameButton.addActionListener(e -> frame.showPanelExtra("JoinGame",1));
|
joinGameButton.addActionListener(e -> frame.showPanel("JoinGame"));
|
||||||
createGameButton.addActionListener(e -> frame.showPanelExtra("JoinGame",0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TOGGLE METHODEN
|
// TOGGLE METHODEN
|
||||||
|
|
Loading…
Reference in New Issue