Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java Applet

Posted on 2002-05-20
6
Medium Priority
?
957 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

824 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