简体   繁体   English

将一个JFrame分配给另一个JFrame

[英]Assigning a JFrame to another JFrame

I am trying to make the current JFrame become a JFrame that is stored in memory. 我试图使当前的JFrame成为存储在内存中的JFrame。 At the moment I am correctly reading the JFrame from memory and I can get it to display but all the action listeners are not working. 目前,我正在正确地从内存中读取JFrame,并且可以显示它,但是所有动作侦听器都无法正常工作。

        gui.dispose();
        gui = savedGUI;
        gui.setVisible(true);

This doesn't seem to be properly setting the current GUI (gui) to the saved version (savedGUI). 这似乎不能正确地将当前的GUI(gui)设置为已保存的版本(savedGUI)。 Is there a different method I should be calling on gui rather than setVisible? 我应该在gui而不是setVisible上调用其他方法吗?

Thanks in advance! 提前致谢!

当我确保所有ActionListeners都实现了Serializable时,此问题已解决。

I don't really understand what you are doing either. 我也不明白你在做什么。 Why do you think you need to refer to the GUI with a single reference variable? 为什么您认为需要使用单个引用变量来引用GUI?

Just do: 做就是了:

savedGui.setVisible( false );

We you want to display the GUI again you do: 我们要再次显示GUI,您可以执行以下操作:

savedGui.setVisible( true );

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

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