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.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JMenu;importjavax.swing.JMenuBar;importjavax.swing.JMenuItem;importjavax.swing.JPanel;importjavax.swing.Timer;publicclassScanLei1extendsJFrameimplementsActionListener{privatestaticfinallongserialVersionUID=1L;privateContainercontentPane;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);contentPane=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(游戏);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);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[]{初级,中级,高级});//加监听/*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=newJPanel();p2.setLayout(newGridLayout(row,col,0,0));for(inti=0;irow*col;i++){btns[i]=newJButton();btns[i].setMargin(newInsets(0,0,0,0));btns[i].setFont(newFont(null,Font.BOLD,25));btns[i].addActionListener(this);btns[i].addMouseListener(newNormoreMouseEvent());p2.add(btns[i]);}contentPane.add(p,BorderLayout.NORTH);contentPane.add(p2,BorderLayout.CENTER);}publicvoidgo(){setVisible(true);}publicstaticvoidmain(String[]args){newScanLei1(扫雷).go();}publicvoidout(int[][]a,JButton[]btns,ActionEvente,inti,intx,inty){intp=1;if(a[x][y]==0){a[x][y]=10;btns[i].setEnabled(false);//33for(intl=y-1;l=y+1;l++){intm=x-1-1;intn=l-1;p=1;System.out.println(a[1][2]);if(n-1&&ncol&&m-1&&mrow){for(intq=0;qrow&&p==1;q++){//col--row;if(((n+col*q)=(m*col))&&((n+col*q)(m+1)*col)){if(a[x-1][l]!=0&&a[x-1][l]!=10){btns[n+col*q].setText(a[x-1][l]+);a[x-1][l]=10;btns[n+col*q].setEnabled(false);}elseif(a[x-1][l]==0){//a[x-1][l]=10;btns[n+col*q].setEnabled(false);out(a,btns,e,n+col*q,x-1,l);////55////a[x-1][l]=10;btns[n+col*q].setEnabled(false);}p=0;}}}p=1;m=x;if(n-1&&ncol&&m-1&&mcol){for(intq=0;qrow&&p==1;q++){if(((n+col*q)=(m*col))&&((n+col*q)(m+1)*col)){if(a[x+1][l]!=0&&a[x+1][l]!=10){btns[n+col*q].setText(a[x+1][l]+);a[x+1][l]=10;btns[n+col*q].setEnabled(false);}elseif(a[x+1][l]==0){out(a,btns,e,n+col*q,x+1,l);///55////a[x+1][l]=10;btns[n+col*q].setEnabled(false);}p=0;}}}}intm=x-1;intn=y-1-1;p=1;if(n-1&&ncol&&m-1&&mcol){for(intq=0;qrow&&p==1;q++){if(((n+col*q)=(m*col))&&((n+col*q)(m+1)*col)){if(a[x][y-1]!=0&&a[x][y-1]!=10){btns[n+col*q].setText(a[x][y-1]+);a[x][y-1]=10;btns[n+col*q].setEnabled(false);}elseif(a[x][y-1]==0){out(a,btns,e,n+col*q,x,y-1);a[x][y-1]=10;btns[n+col*q].setEnabled(false);}p=0;}}}p=1;m=x-1;n=y+1-1;if(n-1&&ncol&&m-1&&mcol){for(intq=0;qrow&&p==1;q++){if(((n+col*q)=(m*col))&&((n+col*q)(m+1)*col)){if(a[x][y+1]!=0&&a[x][y+1]!=10){btns[n+col*q].setText(a[x][y+1]+);a[x][y+1]=10;btns[n+col*q].setEnabled(false);}elseif(a[x][y+1]==0){out(a,btns,e,n+col*q,x,y+1);a[x][y+1]=10;btns[n+col*q].setEnabled(false);}p=0;}}}}}publicvoidactionPerformed(ActionEvente){if(e.getActionCommand()==初级){row=9;col=9;bon=10;a1=newint[bon];b=bon;//setSize(297,377);a=newint[row+2][col+2];this.remove(p2);timer.stop();b1.setText(10);b2.setText(0);b3.setText();btns=newJButton[row*col];p2=newJPanel();p2.setLayout(newGridLayout(row,col,0,0));for(inti=0;irow*col;i++){btns[i]=newJButton();btns[i].setMargin(newInsets(0,0,0,0));btns[i].setFont(newFont(null,Font.BOLD,25));btns[i].addActionListener(this);btns[i].addMouseListener(newNormoreMouseEvent());p2.add(btns[i]);}contentPane.add(p2,BorderLayout.CENTER);//setSize(297,377);this.pack();for(inti=0;irow*col;i++){btns[i].setText();btns[i].setEnabled(true);}for(inti=0;irow+2;i++){for(intj=0;jcol+2;j++){a[i][j]=0;}}}elseif(e.getActionCommand()==中级){row=16;col=16;bon=40;//setSize(33*col,33*row+80);a1=newint[bon];a=newint[row+2][col+2];b=bon;this.remove(p2);timer.stop();b1.setText(40);b2.setText(0);b3.setText();btns=newJButton[row*col];p2=newJPanel();p2.setLay