简体   繁体   中英

Adding a JPanel manually in NetBeans 7.1

I am trying to add a JPanel manually to a JPanel that was created via the Graphic Designer. Since i can't edit in the Generated code i have no idea if i can do that.

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
     newBall2 = new BasketBall("BasketBall",20,400);
     MainpaintPanel mp = new MainpaintPanel();
     this.add(mp);
}

in this code the mp Panel is created successfully but it doesn't show where it's added. i think it's related to the default Layout of the netBeans but it could be something else.

Thanks in Advance.

您也可以尝试使用面板的“ .setVisible(true)”和“ setLocationRelativeTo(component c)”方法

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