LaleaN
asked on
Java Applet
Hi all,
I need to know how to close an applet window that is running off an applet. It is called from the applet. I have tried the following from a class called
class VehicleMaintenance extends Applet
implements ActionListener {
...........
if (source == button1 ) {
Frame f = new Frame("Rent-Ur-Wheels");
VehicleRental vR = new VehicleRental();
f.add(vR);
f.setSize(300, 100);
f.show();
WindowListener l =
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
f.addWindowListener(l);
}
...........
}
but that does not seem to close the window down at all. It displays the window and its contents of the VehicleRental Class - class VehicleRental extends Panel{...} , minimises and maximises but wont close.
Can someone help please
Thanks.
I need to know how to close an applet window that is running off an applet. It is called from the applet. I have tried the following from a class called
class VehicleMaintenance extends Applet
implements ActionListener {
...........
if (source == button1 ) {
Frame f = new Frame("Rent-Ur-Wheels");
VehicleRental vR = new VehicleRental();
f.add(vR);
f.setSize(300, 100);
f.show();
WindowListener l =
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
f.addWindowListener(l);
}
...........
}
but that does not seem to close the window down at all. It displays the window and its contents of the VehicleRental Class - class VehicleRental extends Panel{...} , minimises and maximises but wont close.
Can someone help please
Thanks.
Ovi, that is an answer, not a comment.
sey.
sey.
ASKER
ovi - ty but it did not work - the compiler gives me errors to say
Attempt to use a non-final variable f from a different method.From enclosing blocks only final local varibles are available
Attempt to use a non-final variable f from a different method.From enclosing blocks only final local varibles are available
ASKER
ovi - ty but it did not work - the compiler gives me errors to say
Attempt to use a non-final variable f from a different method.From enclosing blocks only final local varibles are available
Attempt to use a non-final variable f from a different method.From enclosing blocks only final local varibles are available
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ovi,
Ty - i missed it and i even checked but there you go. Thank you again.
Lalea.
Ty - i missed it and i even checked but there you go. Thank you again.
Lalea.
final Frame f = new Frame("Rent-Ur-Wheels");
VehicleRental vR = new VehicleRental();
f.add(vR);
f.setSize(300, 100);
f.show();
WindowListener l =
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
f.setVisible(false);
f.dispose();
// System.exit(0);
}
};
f.addWindowListener(l);
}