在java swing上从子帧管理父帧 [英] managing parent frame from child frame on java swing

查看:195
本文介绍了在java swing上从子帧管理父帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jframe(父),它创建一个输入框(子),我得到一些参数。

I have a jframe (parent) which creates an input frame (child) where I get some parameter.

在孩子框架中我有ok和取消按钮。

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()

这篇关于在java swing上从子帧管理父帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆