Java 按钮中的活动

Java 按钮中的活动,java,swing,applet,Java,Swing,Applet,在我的代码中,在哪里可以插入在此调用的类 我希望发生的是,当我单击按钮时,我要调用的类maze.java将运行,谢谢 public class Main extends Applet { Button mazebutton; Button hexbutton; public void init() { mazebutton = new Button("Create a maxe"); hexbutton = new Button ("Create a

在我的代码中,在哪里可以插入在此调用的类

我希望发生的是,当我单击按钮时,我要调用的类maze.java将运行,谢谢

public class Main extends Applet {

    Button mazebutton;
    Button hexbutton;

    public void init() {

    mazebutton = new Button("Create a maxe");
    hexbutton = new Button ("Create a hexagonal Maze");

    mazebutton.setBounds(20,20,100,30);
    hexbutton.setBounds(20,70,100,40); 

    add(mazebutton);
    add(hexbutton);
    }

}

您只需将代码设置为

button.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
        //here you need to call a function that you need to make
        //on "maze.java"  that returns the values of each variable
        //or starts by launching other function in the same class
        //(maze.java) that activates the game
    }
});