JOptionPane就可以了,不必自己再设计类了。
你运行一下我下面的代码段就知道了。
importjavax.swing.JOptionPane;
importjavax.swing.JDialog;
importjavax.swing.JButton;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
publicclassMultiplyTable1{
publicstaticvoidmain(String[]args){
JOptionPanepane=newJOptionPane(String.format(初级:%1$3d秒%2$20s\n中级:%3$3d秒%4$20s\n高级:%5$3d秒%6$20s,999,匿名,999,匿名,999,匿名));
JButtonbtnRecount,btnOK;
btnRecount=newJButton(重新计分(R));
btnRecount.setMnemonic('R');
btnOK=newJButton(确定);
pane.setOptions(newJButton[]{btnRecount,btnOK});
finalJDialogdlgHeroList=pane.createDialog(null,扫雷英雄榜);
btnRecount.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
dlgHeroList.dispose();
//重新计算
}
});
btnOK.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
dlgHeroList.dispose();
}
});
dlgHeroList.setVisible(true);
}
}