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

    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.setSize(1024, 768);
            testApplet applet = new testApplet();
            frame.add(applet, BorderLayout.CENTER);
    // how can I stop the applet (or destroy it)?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


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

    kind regards,


Similar Threads

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