Click here to Skip to main content
15,906,467 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I hope that all of thing is good.

Today, I have facing problem regarding NetBean IDE.

I am create two seperate classes one is and is extend from JPanel

When I am create GUI of JPanel using Netbeans. I am want to simple add it into my main class.

I am already achive this task whenever using Notepad for doing this all stuff

JPanel panel = new JPanel();


I JPanel is visible on my main class. But my main problem is when I am doing same work on Netbeans JPanel is not showing on main ContentPane. and Netbean is not shwoing any error as well.

My all component(button, TextField, RadioButton etc) is added on class. I am simply add this component into main Class.

I hope that you have give me good and positive reply soon.

Best Regards, class
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

    MyPanel jPanel2 = new MyPanel();



you need to update your GUI after you make those changes. A call for JFrame.revalidate()[^] will do the trick.
Share this answer
when you add any element in Jframe using netbeans, netbeans add this component using its complex layout(see the auto generated code). So when you simply add any element using
,its not appear in the frame.because it is not added to the frame what netbeans use to layout any component. So the best way is that do not add the panel directly in jframe instead first add a jscrollpane in jrame. And then add the required component(jpanel) in scrollpane.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900