/*
* Rhyme2.java
*
* created on 2006-7-3 at 15:41
*/
import java.awt.*;
import java.awt.event.*;
public class Rhyme2 extends Frame implements ActionListener
{
String FIRST="One two,buckle my shoe";
String SECOND="Three four,close the door";
String THIRD="Five six,pick up sticks";
Button btnOK=new Button("OK");
public void createInterface()
{
setLayout(new GridLayout(0,1));
add(new Label(FIRST));
add(new Label(SECOND));
add(new Label(THIRD));
add(btnOK);
btnOK.addActionListener(this);
addWindowListener(new WindowAdapter()
{
public void WindowClosing(WindowEvent event)
{
dispose();
System.exit(0);
}
});
pack();
show();
}
public static void main(String args[])
{
Rhyme2 rhy=new Rhyme2();
rhy.createInterface();
}
public void actionPerformed(ActionEvent event)
{
Object objSource=event.getSource();
if(objSource==btnOK) dispose();
}
}
I compile and run the program on the JCreator Pro software,but it cannot close the close box.Then i press the 'Ok' button ,it can dipose the frame.
who can tell me why?
who can help me?