<分区>
当点击 MenuItem NewGame 时。它有效,但按 F2 无效
mntmNewGame.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int n = JOptionPane.showConfirmDialog(contentPane,"Do you want to play new game ?", "Message!", JOptionPane.OK_CANCEL_OPTION);
}
});
mntmNewGame.addKeyListener(new KeyAdapter() {
public void keyListener(KeyEvent e) {
if(e.getKeyCode()==KeyEvent.VK_F2)
{
int n = JOptionPane.showConfirmDialog(contentPane,"Do you want to play new game ?", "Message!", JOptionPane.OK_CANCEL_OPTION);
}
}
});