I have this kind of error:
Exception in thread "main" Exception in thread "main" Exception in thread "main" java.lang.StackOverflowError
My Code (actually by BroCode):
public class SnakeGame {
public static void main(String[] args) {
GameFrame frame = new GameFrame();
}
}
import javax.swing.JFrame;
public class GameFrame extends JFrame {
public GameFrame() {
this.add(new GameFrame());
this.setTitle("Snake");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.pack();
this.setVisible(true);
this.setLocationRelativeTo(null);
}
}
import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class GamePanel extends JPanel implements ActionListener {
public GamePanel() {
}
@Override
public void actionPerformed(ActionEvent e) {
}
}