2012-01-21 23 views
0

我已經創建了ButtonActionPerformEvent調用dispose Method.how處理方法調用formwindowclosing事件。當前階級和打開另一個類如何在ButtonActionPerformEvent中調用formWindowClosing事件

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

一個更FormWindowClosing事件中,我創建調用setVisible真antoher類對象。

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

請幫我解決這個問題。

回答

3

首先這個問題是不是聽命

1)使用CardLayout寧可打電話create/close/dipose/setVisibleTop Level Container

2)不要創建太多Top Level Container,重用再使用,那麼你有尋找setVisible在這種情況下,你必須設置setDefaultCloseOperation to HIDE_ON_CLOSE,每個Top Level Container通知是有實施了關閉操作

+0

確定不同的方法連我都setDefaultCloseOperation是anothe有可能一個事件調用r事件private void Cmd01ActionPerformed(java.awt.event.ActionEvent evt){GVar = Txt01.getText(); (處理窗口(formWindowClosing(new WindowEvent()))); setDefaultCloseOperation(); getWindows(formWindowClosing());新的GlobalVariableClass2()。setVisible(true);方法如下:private void formWindowClosing(java.awt.event.WindowEvent evt){0} {0} } – javasi

+2

不知道你嘗試了什麼,爲了真正的幫助,請儘快用http://sscce.org/編輯你的問題, – mKorbel

相關問題