我有一个并在初始化时从该框架JFrame
调用 a 。JDialog
在对话框中有一个JButton
,当单击按钮时会JWindow
打开一个新的。
我可以固定窗口在主框架中的位置吗?如何JFrame
从扩展类访问父容器(扩展)JWindow
?
使用SwingUtilities.getWindowAncestor,如果在JWindow
类中,将其称为this
,如果没有,只需将对象放入:
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(myJWindow);