I am trying to add these two JPanel
to JFrame
, however only frame shows and nothing is added. Anyone can help me that what am I missing to add these panels?
import javax.swing.*;
import java.awt.GridLayout;
public class grid_Base extends JFrame {
JFrame mainp = new JFrame();
JPanel p = new JPanel();
JPanel p2 = new JPanel();
clickButtons buttons[] = new clickButtons[100];
public grid_Base() {
super("Battleship");
mainp.setSize(800, 1500);
mainp.setResizable(true);
mainp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainp.setVisible(true);
p.setLayout(new GridLayout(10, 10));
for (int i = 0; i < 100; i++) {
buttons[i] = new clickButtons();
p.add(buttons[i]);
}
mainp.add(p);
p2.setLayout(new GridLayout(10, 10));
for (int i = 0; i < 100; i++) {
buttons[i] = new clickButtons();
p2.add(buttons[i]);
}
mainp.add(p2);
}
}