Results 1 to 13 of 13
Like Tree2Likes
  • 1 Post By camickr
  • 1 Post By camickr

Thread: Killing an applet inside a JPanel

  1. #1
    John5788 is offline Member
    Join Date
    Dec 2011
    Posts
    9
    Rep Power
    0

    Default Killing an applet inside a JPanel

    Hello,

    I have loaded an applet into a JPanel and I would like to simulate a page refresh with my code.

    I have tried to call .stop() or .destroy() on my applet, it immediately crashes Java with a segmentation fault.

    Java Code:
    #
    # A fatal error has been detected by the Java Runtime Environment:
    #
    #  SIGSEGV (0xb) at pc=0x00007f5a87d6c520, pid=28733, tid=140026897590016
    #
    # JRE version: 6.0_29-b11
    # Java VM: Java HotSpot(TM) 64-Bit Server VM (20.4-b02 mixed mode linux-amd64 compressed oops)
    # Problematic frame:
    # C  0x00007f5a87d6c520  _fini+0xf1c9acc8
    I am wondering if there is any elegant way to perform this task?
    Last edited by John5788; 12-26-2011 at 10:01 AM.

  2. #2
    John5788 is offline Member
    Join Date
    Dec 2011
    Posts
    9
    Rep Power
    0

    Default Re: Killing an applet inside a JPanel

    Related question: Is there a way to access the thread that the applet is running? I could try killing the thread if there was someway.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Killing an applet inside a JPanel

    loaded an applet into a JPanel
    Can you explain how you are executing the java program with the applet.
    Is there a browser involved? How does the applet get to the AppletContext and AppletStub objects that are normally provided by a browser?
    What GUI container is the JPanel loaded in?

    access the thread that the applet is running?
    Which method(s) in the Applet are you talking about?

  4. #4
    John5788 is offline Member
    Join Date
    Dec 2011
    Posts
    9
    Rep Power
    0

    Default Re: Killing an applet inside a JPanel

    Hello,

    I build everything the Applet needs to run and create my own AppletStub. The applet normally runs in a browser, but I am not using a browser to launch the applet inside my JPanel.

    I setup my params in a hash map, then I download my JAR using a JarURLConnection. I finally create the applet by using JarURLConnection.loadClass().newInstance().

    Here is a link to my svn with the code on it: john5788 - Revision 35: /Supersonic

    The loading of the applet is performed In the beginning of Supersonic.java, and subsequently, that is also where it is crashing when I attempt a refresh.

  5. #5
    John5788 is offline Member
    Join Date
    Dec 2011
    Posts
    9
    Rep Power
    0

    Default Re: Killing an applet inside a JPanel

    Alright, I figured out its not my code that is crashing the JVM, it is the applet itself. Something is wrong with the applet when destroy or stop is called upon it.

    New question: is there a way to spawn a new JVM for my applet so my program does not crash with the applet?

  6. #6
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: Killing an applet inside a JPanel

    Not sure what you are doing.

    An JApplet is designed to be displayed in a browswer, not a JPanel.

    See: How to Make Applets (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
    DarrylBurke likes this.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Killing an applet inside a JPanel

    applet when destroy or stop is called upon it.
    Are these the methods in your applet that are being called? Who calls those methods?

    I'm not sure Why you are using the applet class? What benefit do you get if there is no browser?

    Can you provide a SSCCE to show the problem. There are too many parts at the link you provided.

  8. #8
    John5788 is offline Member
    Join Date
    Dec 2011
    Posts
    9
    Rep Power
    0

    Default Re: Killing an applet inside a JPanel

    The applet isnt owned by me. I am just creating a third party wrapper for the applet to add tools on top of the applet.

    Here is my short example:

    Java Code:
    AppletLoader appletLoader = new AppletLoader();
    appletLoader.buildApplet();
    // Assume applet is loaded correctly in this example
    Applet myApplet = appletLoader.getApplet();
    JPanel panel = new JPanel();
    panel.add(myApplet);
    
    // Crash here
    myApplet.stop();
    myApplet.destroy();
    I'm not sure if this example is good enough to understand. But as I stated in my last post, I've discovered why my Swing GUI crashes, it is due to the Applet doing something bad that I cannot control. My solution is to try and run the applet in a new JVM to allow that to crash without disturbing the rest of my GUI. Now I need some ideas for this

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Killing an applet inside a JPanel

    Can you get the source for the applet and see what it is doing?

    If you execute the applet in another JVM, what is the purpose of doing it? What results will you get from it?
    You can always use the Runtime and Process classes to start another version of java.

  10. #10
    John5788 is offline Member
    Join Date
    Dec 2011
    Posts
    9
    Rep Power
    0

    Default Re: Killing an applet inside a JPanel

    Ah, maybe I should have included in my example that I am running the applet in a new thread.

    Even in the new thread, when the applet crashes, it takes down the entire JVM unfortunately. Maybe there is no fix for this.

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Killing an applet inside a JPanel

    Look at the applet's source and see what it is doing.

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default Re: Killing an applet inside a JPanel

    Quote Originally Posted by John5788 View Post
    The applet isnt owned by me. I am just creating a third party wrapper for the applet to add tools on top of the applet.
    You could try to remove() the applet from the JPanel and add a new instance of it.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  13. #13
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: Killing an applet inside a JPanel

    You have two methods. Which method stop() or destroy() is causing the problem? As I understand applets stop() is invoked when the browswer loses focus so in case you applet does animation you can pause the animation. Then destroy() would be used when the browswer window closes to release applet resources. If you are trying to use this in an application then I would guess you don't need to use this method.

    Since you haven't posted an SSCCE there is not much more we can do.
    Norm likes this.

Similar Threads

  1. Open .pdf file inside a jpanel
    By pink123 in forum AWT / Swing
    Replies: 6
    Last Post: 10-30-2011, 07:37 AM
  2. An image inside JPanel.
    By Rinas in forum AWT / Swing
    Replies: 4
    Last Post: 10-03-2011, 08:17 PM
  3. Help making a grid inside of a JPanel
    By satanfx55 in forum AWT / Swing
    Replies: 3
    Last Post: 05-13-2011, 08:18 PM
  4. JPanel inside Jtabbed isn't display
    By Ravanelly in forum Advanced Java
    Replies: 7
    Last Post: 06-08-2010, 11:19 PM
  5. How to add JFrame inside JPanel
    By niteshwar.bhardwaj in forum Java 2D
    Replies: 8
    Last Post: 12-13-2009, 09:41 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
  •