You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
package ui;
|
|
|
|
import controller.AppController;
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
|
|
public class DifficultySelectionPanel extends JPanel {
|
|
private AppController controller;
|
|
|
|
public DifficultySelectionPanel(AppController controller) {
|
|
this.controller = controller;
|
|
setLayout(new GridLayout(3, 1, 10, 10));
|
|
setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
|
|
|
// 创建难度按钮
|
|
JButton elementaryBtn = createDifficultyButton("小学", "小学");
|
|
JButton middleBtn = createDifficultyButton("初中", "初中");
|
|
JButton highBtn = createDifficultyButton("高中", "高中");
|
|
|
|
add(elementaryBtn);
|
|
add(middleBtn);
|
|
add(highBtn);
|
|
}
|
|
|
|
private JButton createDifficultyButton(String text, String level) {
|
|
JButton btn = new JButton(text);
|
|
btn.setFont(new Font("微软雅黑", Font.BOLD, 16));
|
|
btn.setPreferredSize(new Dimension(200, 40));
|
|
btn.addActionListener(new ActionListener() {
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
controller.handleDifficultySelection(level);
|
|
}
|
|
});
|
|
return btn;
|
|
}
|
|
} |