Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Running a java applet inside a java window?

  1. #1
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question Running a java applet inside a java window?

    Is it possible to create a window with say a JFrame and inside that have a java applet run?

    Reason why I am asking is because I have a pre-compiled JAR file that I don't have the source code to but I do want to make a JFrame for it. How can I go about doing this?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Running a java applet inside a java window?

    Do you know the name of the Applet class? If so, you should be able to construct an instance of the class, call the appropriate methods (eg init) then add it to a JPanel (which in turn you add to a JFrame)

  3. #3
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: Running a java applet inside a java window?

    No I'm not sure, how would I be able to tell without decompiling?

  4. #4
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Running a java applet inside a java window?

    Quote Originally Posted by copeg View Post
    Do you know the name of the Applet class? If so, you should be able to construct an instance of the class, call the appropriate methods (eg init) then add it to a JPanel (which in turn you add to a JFrame)
    I could be wrong, but I'm not so sure constructing a useable instance of the Applet class is straightforward. Applets typically have a context whose methods they use to do useful things (like load resources). Browsers offer this context. So does the appletviewer executable. But it's not clear how you would roll your own.

    Glancing at the source code Applet instances have a stub variable that knows about the context, the document base etc. There is a setSub() method, but the documentation notes "Sets this applet's stub. This is done automatically by the system".

Similar Threads

  1. [SOLVED] Java Applet not running
    By jdcb92 in forum Java Applets
    Replies: 9
    Last Post: May 16th, 2012, 07:48 PM
  2. Error while running Applet
    By rameshiit19 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: August 1st, 2011, 04:02 AM
  3. Running an Applet With JAR file
    By rameshiit19 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 20th, 2011, 07:10 AM
  4. [SOLVED] Flash animations inside a Java program
    By chronoz13 in forum AWT / Java Swing
    Replies: 1
    Last Post: May 18th, 2011, 03:43 AM
  5. Embed Java inside Java?
    By ActionSplash in forum Java Theory & Questions
    Replies: 3
    Last Post: February 8th, 2011, 09:04 AM

Tags for this Thread