日期:2014-05-20  浏览次数:20766 次

非常非常非常着急,如果有人能够帮忙,我定是感激不尽!
我们要求的JAVA扫雷程序时需要图形界面的,我强调一下是“图形界面”,而且还要有注释和流程图,都是必须得,如果只是程序,不是用图形界面做的是不可以的,注释和流程图也一定要有。希望可以有大侠帮助我一下,要不然今年就要挂科了,我是真的不会。希望大家多多帮忙啊!又重新发一个帖子,是希望能有满意的结果。先谢谢大家了!

------解决方案--------------------
package org.a.Hua;
import java.io.*;
import java.awt.*;
import java.util.Random;
import java.awt.event.*;
import java.sql.*;
import java.util.EventListener;
import javax.swing.JOptionPane;

public class Hua extends Frame implements ActionListener{
Rand bn=new Rand();
int []flag=new int[]{0,0,0,0,0,0,0,0,0,0,0,0,1};


Button b1=new Button(bn.bijiao()+1+"");Button b2=new Button(bn.bijiao()+1+"");
Button b3=new Button(bn.bijiao()+1+"");Button b4=new Button(bn.bijiao()+1+"");
Button b5=new Button(bn.bijiao()+1+"");Button b6=new Button(bn.bijiao()+1+"");
Button b7=new Button(bn.bijiao()+1+"");Button b8=new Button(bn.bijiao()+1+"");
Button b9=new Button(bn.bijiao()+1+"");Button b10=new Button(bn.bijiao()+1+"");
Button b11=new Button(bn.bijiao()+1+"");Button b12=new Button("");

public static void main(String args[]){

new Hua();

}

public Hua (){

//for (int i=0;i<11;i++){

// Button b=new Button(bn.bijiao()+1+"");
//b.setSize(50,50); 如何将分区和按钮充满屏幕
// Panel p=new Panel();
//p.setSize(50,50);
// p.add(b);
// this.add(p);
//b.setName("b"+(i+1));
//p.setName("p"+(i+1));
// b.addActionListener(this);

//}

Panel p1=new Panel();Panel p2=new Panel();
Panel p3=new Panel();Panel p4=new Panel();
Panel p5=new Panel();Panel p6=new Panel();
Panel p7=new Panel();Panel p8=new Panel();
Panel p9=new Panel();Panel p10=new Panel();
Panel p11=new Panel();Panel p12=new Panel();
p1.add(b1);p2.add(b2);
p3.add(b3);p4.add(b4);
p5.add(b5);p6.add(b6);
p7.add(b7);p8.add(b8);
p9.add(b9);p10.add(b10);
p11.add(b11);p12.add(b12);

this.add(p1);this.add(p2);
this.add(p3);this.add(p4);
this.add(p5);this.add(p6);
this.add(p7);this.add(p8);
this.add(p9);this.add(p10);
this.add(p11);this.add(p12);

this.setLayout(new GridLayout(4,3));
this.setSize(160,210);
this.setVisible(true);
this.setResizable(false);
b1.addActionListener(this);b2.addActionListener(this);
b3.addActionListener(this);b4.addActionListener(this);
b5.addActionListener(this);b6.addActionListener(this);
b7.addActionListener(this);b8.addActionListener(this);
b9.addActionListener(this);b10.addActionListener(this);
b11.addActionListener(this);b12.addActionListener(this);
}

public void actionPerformed(ActionEvent e) {
if(b1.getLabel()=="1"&&b2.getLabel()=="2"&&b3.getLabel()=="3"
&&b4.getLabel()=="4"&&b5.getLabel()=="5"&&b6.getLabel()=="6"
&&b7.getLabel()=="7"&&b8.getLabel()=="8"&&b9.getLabel()=="9"
&&b10.getLabel()=="10"&&b11.getLabel()=="11"){

JOptionPane.showMessageDialog(this, "恭喜过关");
new Hua();

}
else if (e.getSource()==b1){

if(flag[2]==1){

b2.setLabel(b1.getLabel());
b1.setLabel("");
flag[2]=0;
flag[1]=1;

}

else if(flag[4]==1){

b4.setLabel(b1.getLabel());
b1.setLabel("");
flag[4]=0;
flag[1]=1;
}
}