Browse Source

add ChoiceHandler & set action command choices

master
Yazan Alaamer 2 years ago
parent
commit
001ecfc3c8
  1. 10
      src/main/java/game/StartDarkSoulsGame.java

10
src/main/java/game/StartDarkSoulsGame.java

@ -30,6 +30,7 @@ public class StartDarkSoulsGame {
JButton StartButton, choice1, choice2, choice3, choice4;
Container con;
TitelScreenHandler tsHandler= new TitelScreenHandler();
ChoiceHandler choiceHandler = new ChoiceHandler();
int playerHP ;
String position;
String weapon;
@ -94,6 +95,7 @@ public class StartDarkSoulsGame {
choice1.setForeground(Color.white);
choice1.setFont(normalFont);
choice1.setFocusPainted(false);
choice1.setActionCommand("c1");
choiceButtonPanel.add(choice1);
choice2 = new JButton("Choice 2");
@ -101,6 +103,7 @@ public class StartDarkSoulsGame {
choice2.setForeground(Color.white);
choice2.setFont(normalFont);
choice2.setFocusPainted(false);
choice2.setActionCommand("c2");
choiceButtonPanel.add(choice2);
choice3 = new JButton("Choice 3");
@ -108,6 +111,7 @@ public class StartDarkSoulsGame {
choice3.setForeground(Color.white);
choice3.setFont(normalFont);
choice3.setFocusPainted(false);
choice3.setActionCommand("c3");
choiceButtonPanel.add(choice3);
choice4 = new JButton("Choice 4");
@ -115,6 +119,7 @@ public class StartDarkSoulsGame {
choice4.setForeground(Color.white);
choice4.setFont(normalFont);
choice4.setFocusPainted(false);
choice4.setActionCommand("c4");
choiceButtonPanel.add(choice4);
playerPanel = new JPanel();
@ -168,6 +173,11 @@ public class StartDarkSoulsGame {
choice3.setText("");
choice4.setText("");
}
public class ChoiceHandler implements ActionListener{
public void actionPerformed(ActionEvent event) {
String yourChoice = event.getActionCommand();
}
}
public class TitelScreenHandler implements ActionListener{
public void actionPerformed(ActionEvent event) {
createGameScreen();

Loading…
Cancel
Save