简体   繁体   中英

How to add jpanel form to a jpanel on runtime in java?

NewProductPanel pPanel=new NewProductJPanel();
pPanel.setVisible(true);
mainPanel.setLayout(new java.awt.BorderLayout());
mainPanel.add(pPanel);

i have created a jPanel form and i want to add it dynamically to my program's mainJFrame, i am using NetBeans..plz help me regarding this..

First, don't call setVisible on pPanel, call it on mainPanel. Also, you may need to call revalidate on mainPanel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM