开发者

Call jpanel form from jFrame form with parameter in java

开发者 https://www.devze.com 2023-04-12 22:25 出处:网络
I am working in jpanel form (drag and drop ) in netbeans. From jframe form开发者_StackOverflow社区 i want to call a jpanel form and want to pass parent frame as parameter . How can I do that in drag a

I am working in jpanel form (drag and drop ) in netbeans. From jframe form开发者_StackOverflow社区 i want to call a jpanel form and want to pass parent frame as parameter . How can I do that in drag and drop in netbeans ?


You can access the parent component of a Swing component using getParent().

See Component.getParent() for details.


In the gui editor, you can edit the custom creation code to call a constructor of your choice. Your panel must still have a no argument blank constructor as it is a bean.

right click your panel->properties->code->custom creation code.

new MyPanel(this)

Or get the parent as mentioned.

0

精彩评论

暂无评论...
验证码 换一张
取 消