Pergunta

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.

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top