Why not use Swing components!? :-)
It seems somehow that AWT Dialog with Modal mode cannot catch
WindowClosing event.
Could someone tell me why and how(mechanism)?
Note:
JDialog need not to attach the Listener !!
I hope my sample
test code can help you.
-------------------
/*
Dialog Problem : 2001.05.10 Reproduction
*/
import java.lang.*;
import java.io.*;
import java.util.*;
import java.text.* ;
import java.math.* ;
import java.applet.* ;
import java.awt.* ;
import java.awt.event.* ;
import javax.swing.* ;
public class testpad {
/** Main Function */
public static void main(
String[] args) {
JFrame w = new JFrame("TestPad Frame") ;
//Frame w = new Frame("TestPad Frame") ;
w.addWindowListener( new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.out.println("Frame Close....") ;
System.exit(0) ;
}
}
) ;
w.pack() ;
w.setSize( 200,200 ) ;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize() ;
w.setLocation( (screen.width - w.getSize().width) / 2 ,
(screen.height - w.getSize().height) / 2 ) ;
w.setVisible(true) ;
Frame wf = new Frame() ; // WorkFrame for TmpDialog
// (in order to close only TmpDialog)
//TmpDialog tp = new TmpDialog(wf,"Error",false) ; // Non-Modal
TmpDialog tp = new TmpDialog(wf,"Error",true) ; // Modal
//tp.addWindowListener( new WindowAdapter(){
// public void windowClosing(WindowEvent e){
// System.out.println("TmpDialog Close....") ;
// ((Frame)((Dialog)e.getSource()).getParent()).dispose() ;
// }
// }
// ) ;
}
}
class TmpDialog extends JDialog {
//class TmpDialog extends Dialog {
TmpDialog(Frame wf , String title , boolean bMode) {
super(wf,title,bMode) ;
System.out.println("TmpPanel() Constructor....") ;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize() ;
JLabel jl1 = new JLabel("Please wait a while",JLabel.CENTER) ;
//Label jl1 = new Label("Please wait a while",Label.CENTER) ;
jl1.setOpaque(true) ;
jl1.setForeground(Color.white) ;
jl1.setBackground(Color.blue) ;
this.getContentPane().add(jl1) ;
//add(jl1) ;
this.pack() ;
this.setSize(300,80) ;
this.setLocation( (screen.width - this.getSize().width) / 2 ,
(screen.height - this.getSize().height) / 2 ) ;
this.toFront() ;
this.setVisible(true) ;
}
}
---------------------------------------
Without a hurt,the heart is hollow....
I like this English maxim. :-)
---------------------------------------
------------------
I am very happy to find this site.