如何获取 JComponent 的顶级容器? [英] How to get the top level container of a JComponent?

查看:36
本文介绍了如何获取 JComponent 的顶级容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法获取组件的顶级容器?例如,我有一个 JToolbar,我想知道该 JToolbar 的顶级容器是我的 JFrame 还是它自己的窗口,即 JDialog.

Is there a way to get the top level container of a component? For example I have a JToolbar and I want to know at one monent the top level container of that JToolbar is my JFrame or is its own window, a JDialog.

推荐答案

SwingUtilities.windowForComponent(...);

这篇关于如何获取 JComponent 的顶级容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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