扫雷游戏Java源代码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
private JButton btn;private JButton[] btns;private JLabel b1; private JLabel b2; private JLabel b3;
private Timer timer;privateint row=9;privateint col=9;privateint bon=10;privateint[][]a; privateint b; privateint[]a1;
private JPanel p, p1,p2, p3;
public ScanLei1(Stringtitle){ super (title);
contentPane =getContentPane(); setSize(297,377);
(400,100,400,500);setDefaultCloseOperation; timer =newTimer(1000,(ActionListener) a=newint[row+2][ col+2];initGUI();
(this);
b2=newJLabel("0" );b3=newJLabel("" );
btns =newJButton[ row* col];
p=newJPanel();
(newBorderLayout());
(p);
(p3,;
etAlignment;
(b1);
(btn);
(b2);
(b3);
(p3,;
publicvoid initGUI(){ p3=newJPanel();
b=bon;
JMenuBarmenuBar=newJMenuBar(); JMenumenu1=newJMenu("游戏");JMenumenu2=newJMenu("帮助");
JMenuItemmi1= newJMenuItem("初级" );JMenuItemmi2= newJMenuItem("中级" );
n=y+1-1;
if (n>-1&&n< col &&m>-1&&mc<ol)
{
for (int q=0;q< row &&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;
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);etEnabled( false );}
JMenuItemmi3= newJMenuItem("高级" );
(this);
(mi1);
(this);
(mi2);
(this);
(mi3);
(menu1);
(menu2);
(menuBar);
b1=newJLabel( bon+"");a1=newint[bon];
btn =newJButton("开始" );
btns [i].addMouseListener( newNormoreMouseEvent());(btns [i]);
}
(p,;
(p2,;
}
publicvoid go(){
setVisible( true);
}
publicstaticvoid main(String[]args){ newScanLei1("扫雷").go();
(p1,;
p2=newJPanel();
(newGridLayout( row,col,0,0));
for (int i=0;i< row *col ;i++){
btns [i]= newJButton("" );
btns [i].setMargin( newInsets(0,0,0,0));
btns [i].setFont( newFont( null,,25));btns [i].addActionListener( this);
p=0;
}
int m=x-1;
int n=y-1-1;
p=1;
if (n>-1&&n< col &&m>-1&&mc<ol)
{
for (int q=0;q< rΒιβλιοθήκη Baiduw &&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;
扫雷游戏
import import import import import import import import import import import import import import import import
import
publicclass ScanLei1 extends JFrameimplements privatestaticfinallongserialVersionUIDprivate Container contentPane;
}
p=0;
}
}
}
p=1;
m=x;
if (n>-1&&n< col &&m>-1&&mc<ol )
{
for (int q=0;q< row&&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){
private Timer timer;privateint row=9;privateint col=9;privateint bon=10;privateint[][]a; privateint b; privateint[]a1;
private JPanel p, p1,p2, p3;
public ScanLei1(Stringtitle){ super (title);
contentPane =getContentPane(); setSize(297,377);
(400,100,400,500);setDefaultCloseOperation; timer =newTimer(1000,(ActionListener) a=newint[row+2][ col+2];initGUI();
(this);
b2=newJLabel("0" );b3=newJLabel("" );
btns =newJButton[ row* col];
p=newJPanel();
(newBorderLayout());
(p);
(p3,;
etAlignment;
(b1);
(btn);
(b2);
(b3);
(p3,;
publicvoid initGUI(){ p3=newJPanel();
b=bon;
JMenuBarmenuBar=newJMenuBar(); JMenumenu1=newJMenu("游戏");JMenumenu2=newJMenu("帮助");
JMenuItemmi1= newJMenuItem("初级" );JMenuItemmi2= newJMenuItem("中级" );
n=y+1-1;
if (n>-1&&n< col &&m>-1&&mc<ol)
{
for (int q=0;q< row &&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;
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);etEnabled( false );}
JMenuItemmi3= newJMenuItem("高级" );
(this);
(mi1);
(this);
(mi2);
(this);
(mi3);
(menu1);
(menu2);
(menuBar);
b1=newJLabel( bon+"");a1=newint[bon];
btn =newJButton("开始" );
btns [i].addMouseListener( newNormoreMouseEvent());(btns [i]);
}
(p,;
(p2,;
}
publicvoid go(){
setVisible( true);
}
publicstaticvoid main(String[]args){ newScanLei1("扫雷").go();
(p1,;
p2=newJPanel();
(newGridLayout( row,col,0,0));
for (int i=0;i< row *col ;i++){
btns [i]= newJButton("" );
btns [i].setMargin( newInsets(0,0,0,0));
btns [i].setFont( newFont( null,,25));btns [i].addActionListener( this);
p=0;
}
int m=x-1;
int n=y-1-1;
p=1;
if (n>-1&&n< col &&m>-1&&mc<ol)
{
for (int q=0;q< rΒιβλιοθήκη Baiduw &&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;
扫雷游戏
import import import import import import import import import import import import import import import import
import
publicclass ScanLei1 extends JFrameimplements privatestaticfinallongserialVersionUIDprivate Container contentPane;
}
p=0;
}
}
}
p=1;
m=x;
if (n>-1&&n< col &&m>-1&&mc<ol )
{
for (int q=0;q< row&&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){