• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot Listen for close box!

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the AWT / Swing forum.
 
There's a city wid manhunt for this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic