Ayuda en buscaminas en java

manu
20 de Julio del 2004
Aca les paso el codigo que hice de un buscaminas en java esta completo tengo 2 errores y no se como solucionarlos, 1 es con el actionListener y otro con la clase quedan, haber si alguien me ouede ayudar



//BUSCAMINAMAS
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;

class Elemento extends JApplet{


JButton b;
boolean s;


Elemento(String a){


b = new JButton(a);
s = false;
}

}
class Jugar extends JApplet {
private int i, j;

private JPanel pane = new JPanel();
private Elemento[][] matriz = new Elemento[20][20];
private boolean minas[][] = new boolean [20][20];

private int num_minas = 100;
private JTextField tf =new JTextField(3);
private JTextField tf1 =new JTextField(3);

private JButton b1 = new JButton("Desactivar");
private JButton b2 = new JButton("Activar");
private void ConstrPanel()
{

pane.setLayout(new GridLayout(20,20));
for ( i=0; i<20; i++)
{
for ( j=0; j<20; j++)
{

minas[i][j] = false;
matriz[i][j]= new Elemento("");
pane.add(matriz[i][j].b);
}
}

for ( i=0; i<20; i++)
{
for ( j=0; j<20; j++)
{



matriz[i][j].b.addActionListener(new ActionListener(){

public void actionPerformed (ActionEvent e){
int cont=0;
if(matriz[i][j].b==(JButton) e.getSource())
{

if(i+1<20)
{
if(matriz[i+1][j].s==true)
{

cont++;
num_minas--;
}
if(!(j-1<0))
{
if(matriz[i+1][j-1].s==true)
{

cont++;
num_minas--;
}
}
if(j+1<20)
{
if(matriz[i+1][j-1].s==true)
{

cont++;
num_minas--;
}
}
}
if(!(j-1<0))
{
if(matriz[i][j-1].s==true)
{

cont++;
num_minas--;
}
}
if(j+1<20)
{
if(matriz[i][j+1].s==true)
{

cont++;
num_minas--;
}
}
if(i>0)
{
if(matriz[i-1][j].s==true)
{
cont++;
num_minas--;
}
if(j>0)
{
if(matriz[i-1][j-1].s==true)
{

cont++;
num_minas--;
}
}
if(j+1<20)
{
if(matriz[i-1][j+1].s==true)
{
cont++;
num_minas--;
}
}

}



if(matriz[i][j].s==true)
{
matriz[i][j].b.setText("*");
destapar();
System.exit(0);

}else{
String a;
a=" " + cont;
matriz[i][j].b.setText(a);
}
}
}//actionPerformed
});//addActionListener

//}//if
}//for1
}//for2

for(int h=0; h<num_minas; h++)
{

i = (int)(Math.random()*20);
j = (int)(Math.random()*20);

matriz[i][j].s= true;

}

}

private void destapar()
{
for(i=0;i<20;i++)
{
for(j=0;j<20;j++)
{
if(matriz[i][j].s==true)
{
matriz[i][j].b.setText("*");
matriz[i][j].b.setBackground(Color.red);
}

}
}

}

private void quedan()
{
cp.add(BorderLayout.SOUTH,new JLabel("-----------QUEDAN "+num_minas+" minas--------"));
}


public static void main (String [] args){


Jugar jue = new Jugar();
jue.init();
//jue.destapar();//sacar

}

public void init(){

JFrame f = new JFrame();
Container cp = f.getContentPane();
f.setSize(850,610);
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
// f.setMaximizable(false);
// f.setMinimizable(false);

f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});

ConstrPanel();

cp.setLayout(new FlowLayout());
cp.add(tf);
cp.add(tf1);
cp.add(b1);
cp.add(b2);


/*JLabel l1=new JLabel("-----------QUEDAN "+num_minas+" minas--------");//no va, va la function quedan
cp.add(l1);*/





b1.addActionListener(new ActionListener(){

public void actionPerformed (ActionEvent e){

do
{

String s,s1;
s=tf.getText();
s1=tf1.getText();


int i= Integer.parseInt(s);
int j= Integer.parseInt(s1);


if(i>=0&&j<=19)
{
matriz[i][j].b.setEnabled(false);
matriz[i][j].b.setText("x");
matriz[i][j].b.setBackground(Color.red);
num_minas--;
quedan();// hacer andar

}else
System.out.println("Ingrese un numeros de 0 a 19");

}while(i<-1||j>20);


}
});

b2.addActionListener(new ActionListener(){

public void actionPerformed (ActionEvent e){

do
{

String s,s1,c,c1;
s=tf.getText();
s1=tf1.getText();
c1="x";


int i= Integer.parseInt(s);
int j= Integer.parseInt(s1);

c=matriz[i][j].b.getText();

if((i>=0 && j<=19)&&(c.compareTo(c1)==0))
{

matriz[i][j].b.setEnabled(true);
matriz[i][j].b.setText("");
matriz[i][j].b.setBackground(new Color(197,197,197));//color por default

num_minas++;
quedan(); //hacer andar

}else
System.out.println("Ingreso mal las coordenadas o en ese lugar no esta un casillero desactivado");

}while(i<-1||j>20);


}
});

cp.add(pane);


f.setVisible(true);
}

}