Call jpanel form from jFrame form with parameter in java
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.
精彩评论