How to display an array graphically?

2

I have a Tabuleiro[][] tabuleiro = New Tabuleiro[20][20] array.

It contains objects of a class not yet implemented, which will have some values, such as cell color and a placeholder.

I would like to know if you can graphically display this array, for example, the fields in the tray, as follows:

That is, that graphically represent this matrix, quite basic even.

    
asked by anonymous 09.04.2015 / 22:07

1 answer

1

You can create a panel and set its size, for example 50x50.

Then you loop another loop to get the rows and columns of the array and create a panel > new.

for(int i = 0; i<n_linhas;i++){
   for(int j=0; i<n_colunas;j++){
       //cria um novo panel, define borda,tamanho,posição inicial
}

The initial position of panel , you take into consideration the size you have defined, and the size of each panel . Then you set the starting position to width: i*height,j*width .

    
22.06.2015 / 22:14