Results 1 to 2 of 2
  1. #1
    afraidofdark is offline Member
    Join Date
    Mar 2010
    Posts
    9
    Rep Power
    0

    Default destroy an applet inside a frame

    hello, I create an applet, and to be able to run it as an application, I add a main method and create a frame, then I add the applet in that frame, when my applet finish it's work, I want to delete it, because it draw shapes on the frame, however stop or destroy methods didn't work, even applet = null didn't work how can I stop that applet ? remove it completely ?

    by the way, there is a timer which always calls paint and update methods of the applet, I think when I destroy the applet, it goes too.

    Java Code:
     public static void main(String[] args) {
            //JFrame frame = new JFrame("");
            GameFrame frame = new GameFrame();
            frame.setLocationRelativeTo(null); // Center the frame
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(1024, 768);
            frame.setVisible(true);
            testApplet applet = new testApplet();
            frame.add(applet, BorderLayout.CENTER);
    
            applet.init();
            applet.start();
            
    // how can I stop the applet (or destroy it)?
    
        }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,573
    Blog Entries
    7
    Rep Power
    21

    Default

    Remove the applet from your frame and nullify all (other) references to it.

    kind regards,

    Jos

Similar Threads

  1. Destroy object
    By anjanesh in forum New To Java
    Replies: 11
    Last Post: 01-02-2010, 07:25 PM
  2. Replies: 7
    Last Post: 11-02-2009, 06:31 PM
  3. frame as an applet
    By shruti in forum Java Applets
    Replies: 0
    Last Post: 07-18-2009, 11:32 AM
  4. Behaviour of stop() and destroy()-methods
    By Zamppa in forum Java Applets
    Replies: 0
    Last Post: 02-10-2009, 09:50 AM
  5. Rectangle expands with applet frame
    By Godzilla in forum New To Java
    Replies: 1
    Last Post: 07-10-2007, 07:14 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
  •