Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在关闭jinternalframe时清除所有数据_Java_Swing_Dispose_Jinternalframe - Fatal编程技术网

Java 如何在关闭jinternalframe时清除所有数据

Java 如何在关闭jinternalframe时清除所有数据,java,swing,dispose,jinternalframe,Java,Swing,Dispose,Jinternalframe,当我关闭jinternalframe时,它选择的jcombobox数据和添加的数据textfeilds保持在关闭时的位置(不保存)。 这是我的结束源代码: private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) { try { if (no != null) { int confirmed = JOptionPane.showConfirmDi

当我关闭jinternalframe时,它选择的jcombobox数据和添加的数据textfeilds保持在关闭时的位置(不保存)。

这是我的结束源代码:

private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
    try {
        if (no != null) {
            int confirmed = JOptionPane.showConfirmDialog(null,
                "Are you sure you want to exit the program?", 
                "Exit Program Message Box",
                JOptionPane.YES_NO_OPTION);

            if (confirmed == JOptionPane.YES_OPTION) {
                this.dispose();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
我无法显示图像,但当我再次打开预关闭的jinternalframe时,新jinternalframe上的所有选定数据也相同

我以前试过这个代码。但当我点击关闭按钮时,jinternalframe甚至没有关闭。 这是旧代码:

NewOrder no;
try {
    if (no != null) {
        int confirmed = JOptionPane.showConfirmDialog(null,
            "Are you sure you want to exit the program?", 
            "Exit Program Message Box",
            JOptionPane.YES_NO_OPTION);

        if (confirmed == JOptionPane.YES_OPTION) {
            this.dispose();
        }
    }
} catch (Exception e) {
    e.printStackTrace();
}
这根本不起作用。。请帮忙。如果你需要更多的解释,请询问

再次编辑问题。


假设我在internalframe中填写了姓名和地址,并在不保存任何数据的情况下关闭了它。。如果我再次打开它,输入的数据就会在那里。我使用给定的第一个源代码关闭jinternalframe。第二个源代码甚至不起作用

你能把字迹弄清楚吗?我不是以英语为母语的人,但这看起来有点草率。慢慢来,解释一下你现在遇到的实际问题。我怀疑即使在窗格关闭后,仍有一些静态变量保持状态。@Kroltan我编辑了问题。您不能重新打开已处理的窗口。您的问题仍然没有意义。@EJP但它的开放性非常好。我也应该添加开放源代码。关闭方法很好。你们怎么开门?如果重复使用引用,则会得到相同的帧。相反,在打开时创建一个新实例,这样它就会是新的。