简体   繁体   English

如何确定JDialog是否有子级?

[英]How do I determine if a JDialog has children?

I've got a custom window class that is a couple levels down extending a JDialog. 我有一个自定义窗口类,它在扩展JDialog的基础上向下扩展了几层。 We have windows that we create and sometimes we create new windows as children of existing windows using the constructor that takes a parent argument. 我们有创建的窗口,有时我们使用带有父参数的构造函数将新窗口创建为现有窗口的子窗口。

I need to put some code somewhere in our custom class that does something different depending on whether not the window has children. 我需要在自定义类中的某些位置放置一些代码,这取决于窗口是否有子对象,从而有所不同。 I know of getParent() , etc, and I can see that I can loop through the components of the window, but for the life of me, I can't seem to figure out how to determine whether or not my current window has any child windows. 我知道getParent()等,并且可以看到可以循环浏览窗口的各个组件,但是对于我自己的一生,我似乎无法弄清楚如何确定当前窗口是否有任何窗口子窗口。

Is there a way to do this? 有没有办法做到这一点? Any help is, as always, much appreciated. 与往常一样,任何帮助都将受到赞赏。

请参见Window.getOwnedWindows()。

will getOwnedWindows() do? getOwnedWindows()做什么? It belongs to java.awt.Window which in JDialog 's parent lineage. 它属于JDialog的父系中的java.awt.Window

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM