Solved

Java Applet

Posted on 2002-05-20
6
948 Views
Last Modified: 2013-11-23
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.
0
Comment
Question by:LaleaN
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 7023237
if (source == button1 ) {
          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);
}

0
 
LVL 1

Expert Comment

by:sey7
ID: 7023435
Ovi, that is an answer, not a comment.

sey.
0
 

Author Comment

by:LaleaN
ID: 7023500
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:LaleaN
ID: 7023527
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
0
 
LVL 9

Accepted Solution

by:
Ovi earned 50 total points
ID: 7023827
In my original post was like this :
final Frame f = new Frame("Rent-Ur-Wheels");

this meens the f variable is final and you will not get any errors.


Hi sey7 !
0
 

Author Comment

by:LaleaN
ID: 7023847
Ovi,

Ty - i missed it and i even checked but there you go.  Thank you again.

Lalea.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 38
How can I do a Massively massive community reviewing-and-grading site? 7 69
more than one jdk and one jre 1 30
tomcat not starting 6 23
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now