Files
SAE21_2023/src/HomeButtonClickListener.java

51 lines
1.5 KiB
Java
Raw Normal View History

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.BorderLayout;
import javax.swing.JOptionPane;
2024-04-09 17:13:23 +02:00
/**
* Listener for button clicks in the menu.
* It performs different actions based on the button clicked.
*/
2024-04-09 17:13:23 +02:00
class HomeButtonClickListener implements ActionListener {
private Window window;
2024-04-09 17:13:23 +02:00
private DialogManager rulesDialogManager;
private DialogManager howToPlayDialogManager;
/**
* Constructs a ButtonClickListener with the specified window.
* @param window The window where the actions will be performed.
*/
2024-04-09 17:13:23 +02:00
public HomeButtonClickListener(Window window) {
this.window = window;
2024-04-09 17:13:23 +02:00
this.rulesDialogManager = new RulesDialogManager();
this.howToPlayDialogManager = new HowToPlayDialogManager();
}
/**
* Performs an action based on the button clicked.
* @param e The ActionEvent representing the button click.
*/
@Override
public void actionPerformed(ActionEvent e) {
String buttonText = ((Button) e.getSource()).getText();
switch (buttonText) {
case "Jouer":
2024-04-09 17:13:23 +02:00
// à faire
break;
case "Règles":
2024-04-09 17:13:23 +02:00
rulesDialogManager.showDialog();
break;
case "Comment jouer ?":
2024-04-09 17:13:23 +02:00
howToPlayDialogManager.showDialog();
break;
case "Quitter":
System.exit(0); // Quitter le programme
break;
default:
break;
}
}
}