boas
Eu gostaria muito que me ajudassem num erro que não entendo.
Exception in thread “main” java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1041)
at java.awt.Container.add(Container.java:365)
at jogo_xadrez.Tabuleiro.(Tabuleiro.java:46)
at jogo_xadrez.Main.main(Main.java:19)
Java Result: 1
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package jogo_xadrez;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
*
* @author
*/
public class Tabuleiro extends JFrame {
private JButton[][] tab;
private int linha;
private int coluna;
private JPanel painel;
private JButton botao;
Tabuleiro(int linha, int coluna){
setTitle("Jogo de Xadrez");
setSize(800,800);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.painel = new JPanel();
this.add(this.painel);
this.linha = linha;
this.coluna = coluna;
this.tab = new JButton[linha][coluna];
for (int i = 0; i < linha; i++) {
for (int j = 0; j < coluna; j++) {
this.tab[i][j] = new JButton("");
this.tab[i][j].setVisible(true);
}
}
for (int i = 0; i < linha; i++) {
for (int j = 0; j < coluna; j++) {
this.painel.add(this.tab[i][j]);
}
}
}
package jogo_xadrez;
/**
*
* @author
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Tabuleiro t = new Tabuleiro(8,8);
t.setVisible(true);
}
}
Desde já agradeço.