Basically, I have created a simple window. I am having trouble adding a window listener so that when the user clicks the x to exit the program, it exits. Here is the code I have.
package javagraphics;
import java.awt.*;
import java.awt.event.*;
public class DispGraphics
{
public static void main(String args[])
{
Frame myFrame = new Frame("My Window");
myFrame.setLayout(new BorderLayout());
Label myLabel = new Label("Hello World!");
myFrame.add(myLabel, BorderLayout.CENTER);
myFrame.setSize(200, 200);
myFrame.show();
}
}
What do I need to add to it so that I can exit program with x on top right of window? Thanks.