Java Reference
In-Depth Information
String actionCommand = e.getActionCommand();
if (actionCommand.equals("Yes"))
System.exit(0);
else if (actionCommand.equals("No"))
dispose(); //Destroys only the ConfirmWindow.
else
System.out.println(
"Unexpected Error in Confirm Window.");
}
} //End of inner class ConfirmWindow
public static void main(String[] args)
{
WindowListenerDemo3 demoWindow =
new WindowListenerDemo3();
demoWindow.setVisible( true );
}
public WindowListenerDemo3()
{
setSize(WIDTH, HEIGHT);
setTitle("Window Listener Demonstration");
setDefaultCloseOperation(
JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener( this );
getContentPane().setBackground(Color.LIGHT_GRAY);
JLabel aLabel =
new JLabel("I like to be sure you are sincere.");
add(aLabel);
}
//The following are now methods of the class WindowListenerDemo3:
public void windowOpened(WindowEvent e)
{}
public void windowClosing(WindowEvent e)
{
ConfirmWindow checkers = new ConfirmWindow();
checkers.setVisible( true );
}
public void windowClosed(WindowEvent e)
{}
public void windowIconified(WindowEvent e)
{}
Search WWH ::




Custom Search