如何在 ButtonActionPerformEvent 中调用 formWindowClosing 事件 [英] how to call formWindowClosing event in ButtonActionPerformEvent

查看:24
本文介绍了如何在 ButtonActionPerformEvent 中调用 formWindowClosing 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了 ButtonActionPerformEvent 调用 dispose Method.how dispose 方法调用 formwindowclosed 事件.为当前班级并打开另一个班级

i have created ButtonActionPerformEvent call dispose Method.how dispose method call formwindowclosing event. for current class and open another class

private void Cmd01ActionPerformed(java.awt.event.ActionEvent evt) {                                      
            GVar=Txt01.getText();
            dispose(**formWindowClosing**(-)); // how i can pass form closing event here.
    } 

另外一个 FormWindowClosing 事件我用 setVisible True 创建了另一个类对象.

one more FormWindowClosing Event i create antoher class object with setVisible True.

 private void formWindowClosing(java.awt.event.WindowEvent evt) {                                   
        new GlobalVariableClass2().setVisible(true);  //another class
} 

请帮我解决这个问题.

推荐答案

首先这个问题没有答案

1) 使用 CardLayout 而不是调用 create/close/dipose/setVisible 用于顶级容器

1) use CardLayout rather that to call create/close/dipose/setVisible for Top Level Container

2) 不要创建批次 Top Level Container,将其重用于其他用途,然后您必须查找 setVisible,在这种情况下,您必须设置 setDefaultCloseOperation 为 HIDE_ON_CLOSE,注意每个顶级容器 是否为关闭操作实现了不同的方法

2) don't create lots Top Level Container, reuse that for another usage, then you have to look for setVisible and in this case you have to set setDefaultCloseOperation to HIDE_ON_CLOSE, notice for each Top Level Container is there implemented different methods for close operations

这篇关于如何在 ButtonActionPerformEvent 中调用 formWindowClosing 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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