I am working on a project with GridLayout. Currently, I am having trouble replacing a JPanel with GridLayout with another JPanel with GridLayout in my JFrame. Here is the code.
public JFrame frame = new JFrame();
public JPanel pan = new JPanel();
public void replace() {
frame.remove(pan);
pan = new JPanel();
GridLayout grid = new GridLayout(8,8);
pan.setLayout(grid);
frame.add(pan);
frame.invalidate();
frame.revalidate();
frame.repaint();
}
Much help would be appreciated. Thanks