Java:在打开的jPanel和jFrame之间交换数据
从已经打开的 jPanel 中,我使用以下方法打开 jFrame“FastSearch”搜索窗口:
new FastSearch().setVisible(true);
其中列出了搜索结果。当我选择搜索结果之一时,我想将值发送回打开子 jFrame“FastSearch”的父 jPanel。
我认为它看起来像这样:
ParentWindow.targetVariable = theValueFromTheOpenedForm;
但当然,这是行不通的。
如何在打开的 jPanel 和 jFrame 之间传递数据?
提前致谢
From the already opened jPanel I open the jFrame "FastSearch" search window using the following method:
new FastSearch().setVisible(true);
which lists the search results. When I select one of the search results I want to send the value back to the parent jPanel which opened the child jFrame "FastSearch".
I thought it would look something like this:
ParentWindow.targetVariable = theValueFromTheOpenedForm;
But of course, it doesn't work.
How do I pass data between opened jPanel and jFrame?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要以某种方式将该对象传递给
FastSearch
类。在构造函数中或通过其他方法。我假设可能有一个侦听器接口。You'll need to pass the object through to the
FastSearch
class in some way. Either in the constructor or through some other method. I'm assuming there is probably a listener interface.