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.

有帮助吗?

解决方案

you could also try using the ".setVisible(true)" and "setLocationRelativeTo(component c)" methods of the panel

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top