有没有办法更改JDialog的所有者? [英] Is there a way to change the owner of a JDialog?

查看:63
本文介绍了有没有办法更改JDialog的所有者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常具体的问题,我想知道是否有一种方法可以更改JDialog的所有者(可以使用构造函数进行设置).我想没有官方的"可能性(黑客除外),但是我想确保自己没有错过任何事情.有关该主题的任何想法或提示都会有所帮助,已经感谢...

I have a very specific problem, and I wanted to know if there is a way to change the owner of a JDialog (it can be set using the constructor). I suppose there is no "official" possibility (other than a hack), but I wanted to make sure I didn't miss something. Any ideas or hints on the topic would be helpful, thanks already...

推荐答案

如果您的问题是在应用程序生命周期中如何重用对话框,那么更好的方法是:

If your question is about how to reuse dialogs during your application lifecycle, then a better way is to:

  1. 将所有对话框内容定义为JPanel子类
  2. 并使用现有的JPanel子类实例实例化一个新的JDialog

对于第2点,您当然可以使用面板的惰性评估(仅在首次使用时实例化,然后再使用).

For point 2, you can of course use lazy evaluation of the panels (instantiate upon first use only, then reuse).

您还需要使面板实现(自己的)某个界面,该界面允许您重新初始化它们以在新的JDialog中重用(重新初始化通常意味着擦除所有字段的内容,或将这些字段设置回其默认值).值).

You will also need to have your panels implement some interface (of your own) that allows you to re-initialize them for reuse in a new JDialog (reinit typically means erasing all fields contents, or setting these fields back to their default values).

这篇关于有没有办法更改JDialog的所有者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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