1

I just start learning java using netbean. I am now have one jFrame containing a jPanel1, and one jPanel2 class. I want to add jPanel2 into jPanel1 in jFrame in certain condition. So i've tried

if(split){
                jPanel2 = new jPanel2();
                jPanel1.add(jPanel2);
                Panel1.setVisible(true);
            }

I have searched over the internet and found out sort of methods to do this is using GridLayout,CardLayout or something . But i still can not do it like those tutorial even i did the same thing.Thanks so much , please don't mind for asking stupid question.

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
B way Ng
  • 13
  • 4
  • Call `jPanel1.revalidate()` followed by `jPane1.repaint()` to trigger a layout and paint pass after you've added `jPanel2` to `jPanel1` – MadProgrammer Mar 19 '18 at 04:41

0 Answers0