JMenuItem againItem = startFile.add("再玩一次");//建立子菜单
JMenuItem heroItem = startFile.add("英雄榜");
JMenuItem howItem = helpFile.add("如何游戏");
JMenuItem writerItem = aboutFile.add("制作组成员");
JMenuItem callItem = aboutFile.add("联系方式");
againItem.addActionListener(new ActionHandler());//建立鼠标监听器
}
}
class ActionHandler implements ActionListener{
public void actionPerformed(ActionEvent event){
JOptionPane.showMessageDialog(null,"Hello world!","Display",JOptionPane.INFORMATION_MESSAGE);
}
}
或者:
JMenuItem againItem = startFile.add("再玩一次");//建立子菜单
JMenuItem heroItem = startFile.add("英雄榜");
JMenuItem howItem = helpFile.add("如何游戏");
JMenuItem writerItem = aboutFile.add("制作组成员");
JMenuItem callItem = aboutFile.add("联系方式");
againItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
JOptionPane.showMessageDialog(null,"Hello world!","Display",JOptionPane.INFORMATION_MESSAGE);
}
}
);//建立鼠标监听器
}
}
rtearteratetrtretfgf tgreghehthrssrrth