Added new class "startLocalGame.java" containing first UI code

This commit is contained in:
Joshua 2024-10-29 18:56:20 +01:00
parent 68999b3464
commit f798125ced
3 changed files with 75 additions and 3 deletions

View File

@ -2,6 +2,7 @@
<library name="jlayer-1.0.3"> <library name="jlayer-1.0.3">
<CLASSES> <CLASSES>
<root url="jar://$USER_HOME$/Downloads/jlayer-master/jlayer-master/target/jlayer-1.0.3.jar!/" /> <root url="jar://$USER_HOME$/Downloads/jlayer-master/jlayer-master/target/jlayer-1.0.3.jar!/" />
<root url="jar://$USER_HOME$/Downloads/jlayer-1.0.3.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@ -2,9 +2,8 @@ public class HalloSchiffeVersenken {
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
/* Blop wurde eliminiert
System.out.println("HelloSchiffeVersenekn"); System.out.println("HelloSchiffeVersenekn");
System.out.println("sound"); System.out.println("sound");
SoundHandler.playSound("hit"); SoundHandler.playSound("hit");
Thread.sleep(3000); Thread.sleep(3000);
@ -13,7 +12,8 @@ public class HalloSchiffeVersenken {
SoundHandler.setSoundOn(false); SoundHandler.setSoundOn(false);
System.out.println("sound off"); System.out.println("sound off");
SoundHandler.playSound("hit"); SoundHandler.playSound("hit");
*/
startLocalGame huso = new startLocalGame();
} }
} }

71
src/startLocalGame.java Normal file
View File

@ -0,0 +1,71 @@
import javax.swing.*;
public class startLocalGame {
// Frame
JFrame frame = new JFrame("Lokales Spiel");
// Labels
JLabel frameTitle = new JLabel("Lokales Spiel");
JLabel semesterlable = new JLabel("Semester");
JLabel leftPlayerName = new JLabel("Name");
JLabel rightPlayerName = new JLabel("KI-Level");
// Buttons
JButton backButton = new JButton("Zurück");
JButton leftPlayerLeftButton = new JButton("<-");
JButton leftPlayerRightButton = new JButton("->");
JButton semesterUpButton = new JButton("^");
JButton semesterDownButton = new JButton("v");
JButton rightPlayerLeftButton = new JButton("<-");
JButton rightPlayerRightButton = new JButton("->");
JButton startButton = new JButton("Start!");
startLocalGame() {
// Erstelle Frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1500, 1000);
// Setzt den Layout-Manager auf null, um absolute Positionierung zu ermöglichen
frame.setLayout(null);
// Erstelle Label
frameTitle.setBounds(50, 20, 200, 30);
frame.add(frameTitle);
semesterlable.setBounds(400, 300, 200, 30);
frame.add(semesterlable);
leftPlayerName.setBounds(50, 550, 200, 30);
frame.add(leftPlayerName);
rightPlayerName.setBounds(750, 550, 200, 30);
frame.add(rightPlayerName);
// Erstellt Buttons
backButton.setBounds(800, 20, 120, 30);
frame.add(backButton);
leftPlayerLeftButton.setBounds(50, 450, 50, 50);
frame.add(leftPlayerLeftButton);
leftPlayerRightButton.setBounds(250, 450, 50, 50);
frame.add(leftPlayerRightButton);
semesterUpButton.setBounds(500, 400, 50, 50);
frame.add(semesterUpButton);
semesterDownButton.setBounds(500, 600, 50, 50);
frame.add(semesterDownButton);
rightPlayerLeftButton.setBounds(750, 450, 50, 50);
frame.add(rightPlayerLeftButton);
rightPlayerRightButton.setBounds(950, 450, 50, 50);
frame.add(rightPlayerRightButton);
startButton.setBounds(400, 750, 100, 50);
frame.add(startButton);
frame.setVisible(true);
}
}