문제

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