資源描述:
《掃雷游戲Java源代碼》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、.掃雷游戲Java源代碼importjava.awt.BorderLayout;importjava.awt.Container;importjava.awt.Font;importjava.awt.GridLayout;importjava.awt.Insets;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.MouseAdapter;importjava.awt.event.MouseEvent;importjavax.swing.JBut
2、ton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JMenu;importjavax.swing.JMenuBar;importjavax.swing.JMenuItem;importjavax.swing.JPanel;importjavax.swing.Timer;publicclassScanLei1extendsJFrameimplementsActionListener{privatestaticfinallongserialVersionUID=1L;privateCo
3、ntainercontentPane;privateJButtonbtn;privateJButton[]btns;privateJLabelb1;privateJLabelb2;privateJLabelb3;privateTimertimer;privateintrow=9;privateintcol=9;privateintbon=10;privateint[][]a;privateintb;privateint[]a1;privateJPanelp,p1,p2,p3;publicScanLei1(Stringtitle){super(title);contentPa
4、ne=getContentPane();..setSize(297,377);this.setBounds(400,100,400,500);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);timer=newTimer(1000,(ActionListener)this);a=newint[row+2][col+2];initGUI();}publicvoidinitGUI(){p3=newJPanel();b=bon;JMenuBarmenuBar=newJMenuBar();JMenumenu1=newJMenu("游戲")
5、;JMenumenu2=newJMenu("幫助");JMenuItemmi1=newJMenuItem("初級");JMenuItemmi2=newJMenuItem("中級");JMenuItemmi3=newJMenuItem("高級");mi1.addActionListener(this);menu1.add(mi1);mi2.addActionListener(this);menu1.add(mi2);mi3.addActionListener(this);menu1.add(mi3);menuBar.add(menu1);menuBar.add(menu2);
6、p3.add(menuBar);b1=newJLabel(bon+"");a1=newint[bon];btn=newJButton("開始");btn.addActionListener(this);b2=newJLabel("0");b3=newJLabel("");btns=newJButton[row*col];p=newJPanel();p.setLayout(newBorderLayout());contentPane.add(p);p.add(p3,BorderLayout.NORTH);//combo=newJComboBox(newObject[]{"初級
7、","中級","高級"});//加監(jiān)聽/*combo.addItemListener(newItemListener(){}});*/p1=newJPanel();//在那個位置..//((FlowLayout)p1.getLayout()).setAlignment(FlowLayout.RIGHT);p1.add(b1);p1.add(btn);p1.add(b2);p1.add(b3);p.add(p3,BorderLayout.NORTH);p.add(p1,BorderLayout.CENTER);p2=