当我点击名为“start”的按钮时,我想在gui_Game
中启动一个班级。在gui_Game
设置标题中,有三个按钮。
此代码位于Main
类:
private class Start implements ActionListener{
public void actionPerformed(ActionEvent e) {
JButton b = (JButton) e.getSource();
if (b.getText().equals("start"))
// I want to add here
}
}
这是gui_Game
来源:
public class gui_Game extends JFrame{
private JButton button;
private JButton button1;
private JButton button2;
private JButton button3;
private JButton button4;
private JButton button5;
private JButton button6;
private JButton button7;
private JButton button8;
private JLabel Stage;
public gui_Game() throws IOException
{
// .. code ..
}
public static void main(String[] args) throws IOException
{
gui_Game main = new gui_Game();
main.setVisible(true);
}
}
在gui_Game
中,它会创建一个新窗口和三个按钮。