在 java swing 上从子框架管理父框架
我有一个 jframe(父),它创建一个输入框架(子),我在其中获取一些参数.
I have a jframe (parent) which creates an input frame (child) where I get some parameter.
在子"框架中,我有确定"和取消"按钮.
In the "child" frame I have "ok" and "cancel" buttons.
当按下ok"按钮时,父框架需要更新新数据.
When "ok" button is pressed, the parent frame needs to be updated with new data.
最好的方法是什么??
推荐答案
在创建(或显示)子框架时传入对父框架的引用.这将需要一个重载的构造函数或显示方法.
Pass in a reference to the parent frame when you create (or display) the child frame. This will require an overloaded constructor or display method.
一旦子级拥有引用,它当然可以调用父级公开的任何方法,例如 UpdateDate()
Once the child has the reference, it can of course call any method that the parent exposes as public, like UpdateDate()
相关文章