Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/04/2014, 13:16
lutxi
 
Fecha de Ingreso: diciembre-2007
Mensajes: 24
Antigüedad: 16 años, 5 meses
Puntos: 0
Problemas con Matrices

Buenas noches,

Estoy intentando asignar un valor de la matriz tableroCor a tablero ( tengo que hacer un mapa de coordinadas) y no puedo... ¿Alguien me podría ayudar?

No sé donde falla...

public class Tablero extends JPanel implements ActionListener
{
Mapa mapa;

Timer timer;
int filas=11;
int columnas=20;
int posX=105;
int posY=100;
JLabel [][] tablero;
String [][] tableroCor;
int alto=20;
int ancho=20;


public Tablero()
{
mapa= new Mapa();
tablero= new JLabel[2][20];
tableroCor= new String [2][20];


String[][] tableroCor={{"A","A","A","A","A","A","A","A","A"," A","A","A","A","A","A","A","A","A","A","A"},{"A"," B","C","C","C","A","C","C","C","C","C","C","C","C" ,"A","C","C","C","B","A"}};//{0,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,0},{0,1,0,1 ,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0},{0,1,0,1,0,0,1,0 ,0,3,3,0,0,1,0,0,1,0,1,0},{0,1,1,1,1,1,1,0,3,3,3,3 ,0,1,1,1,1,1,1,0},{0,1,0,1,0,0,1,0,0,0,0,0,0,1,0,0 ,1,0,1,0},{0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0 },{0,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,0},{0,2,1 ,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,2,0},{0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0}};

addKeyListener(new Tadaptadora());
setFocusable(true);

setBackground(Color.black);
timer= new Timer (30,this);
timer.start();

}




public void paint (Graphics g)
{
int x2=30;
int y2=30;
super.paint(g);
Graphics2D g2d =(Graphics2D) g;
g2d.drawImage(pacman.getImage(),pacman.getX(),pacm an.getY(),this);
//tablero=mapa.getMap();

for (int i=0; i<tablero.length; i++)
{
for (int j=0; j<tablero[i].length; j++)
{

tablero[i][j]=new JLabel();
tablero[i][j].setBounds(x2,y2,30,30);
tablero[i][j].setText(tableroCor[i][j].value);
tablero[i][j].setForeground(Color.GRAY);

add(tablero[i][j]);




}
}

}