質問

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