Click to See Complete Forum and Search --> : Close Button Not Working


E. Heineken
February 29th, 2000, 05:08 PM
How come sometimes the close buttons, the "x" on the top right corner on the forms aren't responding? I'm very sure the forms are working well coz I made a command button that closes the application. Any solution to this? Thanx

keithmcelhinnney
March 2nd, 2000, 09:46 AM
You have to be a component listener to the frame/dialog and use this

public void componentClosed(ComponentEvent e)
{
hide();
}


keith

ytsau
March 2nd, 2000, 12:20 PM
Or you may create your own frame class and use it instead of Frame. Do this:

class MyFrame extends Frame
{
public boolean handleEvent(Event e) {
if(e.id==Event.WINDOW_DESTROY) {
dispose();
}
}
}




Good luck, ytsau

ytsau
March 2nd, 2000, 12:26 PM
Or you may create your own frame class and use it instead of Frame. Do this:


class MyApplet extends Applet
{
MyFrame frame;
init()
{
frame = new MyFrame();
frame.show();
}
public boolean action(Event e, Object o) {
if(e.target==mybutton) {
frame.dispose();
}
}

class MyFrame extends Frame
{
public boolean handleEvent(Event e) {
if(e.id==Event.WINDOW_DESTROY) {
dispose();
}
}
}



The applet will create a new frame. It can be closed by clicking its [x], or you can click your button named mybutton to close it. Good luck, ytsau