Java Reference
In-Depth Information
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)
{}
public void
windowDeiconified(WindowEvent e)
{}
public void
windowActivated(WindowEvent e)
{}
public void
windowDeactivated(WindowEvent e)
{}
}
5.
JButton magicButton =
new
JButton("Magic Button");
ImageIcon wizardIcon =
new
ImageIcon("wizard.gif");
magicButton.setIcon(wizardIcon);