Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java Applet

Posted on 2002-05-20
6
Medium Priority
?
956 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

704 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