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
Printable View
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
You have to be a component listener to the frame/dialog and use this
public void componentClosed(ComponentEvent e)
{
hide();
}
keith
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
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