Results 1 to 4 of 4

Thread: closing Frame

  1. #1
    twinkle is offline Member
    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Question closing Frame

    hello every body...


    my program is following

    import java.awt.*;
    import java.awt.event.*;

    class Frame1 extends Frame
    {
    Frame1(String title)
    {
    super(title);
    addWindowListener(new WindowAdapter()
    {
    public void windowClosing(WindowEvent me){ f1.dispose();}
    });
    }


    }

    public class Frameapplication
    {
    public static void main(String arg[])
    {
    Frame1 f1 = new Frame1("my first frame");
    f1.show();
    f1.setSize(200,200);
    }
    }



    Compilation of program is..

    C:\msc>javac Frameapplication.java
    Frameapplication.java:11: error: cannot find symbol
    public void windowClosing(WindowEvent me){ f1.dispose();}
    ^
    symbol: variable f1
    Note: Frameapplication.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    1 error


    now how can i solve error in this program please give me answer??
    Last edited by twinkle; 07-28-2012 at 09:59 AM.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: closing Frame

    Don`t create graphical user interfaces if you don`t know the basics
    f1.dispose();
    ->
    dispose();
    or
    Frame1.this.dispose();

    f1 isn`t visible there

  3. #3
    twinkle is offline Member
    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Default Re: closing Frame

    ohk.... thank you so much....

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

Similar Threads

  1. Closing Child Frame
    By coollucky in forum AWT / Swing
    Replies: 7
    Last Post: 11-24-2011, 04:19 PM
  2. frame closing
    By manish007g in forum AWT / Swing
    Replies: 4
    Last Post: 09-24-2011, 10:15 PM
  3. Replies: 4
    Last Post: 01-18-2011, 08:22 AM
  4. Java slave Frame access to its owner main frame problem
    By cagdaseckin in forum New To Java
    Replies: 0
    Last Post: 12-10-2010, 10:40 AM
  5. Replies: 2
    Last Post: 05-28-2010, 02:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •