Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot Listen for close box!  RSS feed

 
Smith Jon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/*
* 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?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you use the Adapter classes, your override method must match

public void WindowClosing(WindowEvent event)
public void windowClosing(WindowEvent event)//<--small w
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the AWT / Swing forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!