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