Hi, I was wondering, is their any way to draw/add a JFrame inside a JApplet. I have this JFrame that needs to be in Applet form, and I don't know how to go about doing it. Completely re-writing it is out of the question (5 or so classes). I didn't write it, my teacher did, and he needs it in JApplet form. He would do it himself, but he doesn't have time. This is NOT homework, I'm taking this on of my own free will. Any help would be GREATLY appreciated =]

Recommended Answers

All 5 Replies

No, you're going to have to convert the top-level window to JApplet. There really aren't too many things to change in many cases. If the other classes are lightweight components, it should be fairly trivial.
You can find a lot of information here: http://java.sun.com/docs/books/tutorial/deployment/applet/index.html

*sigh* I was afraid of that =[ lol, oh well, you gotta do what you gotta do ;)

It's usually not too much trouble to convert from a JFrame to a JApplet as long as you don't run up against the tighter security concerns of applets. Just change the "extends JFrame" to "extends JApplet" and divide the code into the appropriate applet life cycle methods (init, start, stop, destroy). If you run into troubles, just post the code and your questions back here.

ok, thanks =]

Too late for the OP, but I found a much easier way (can't remember where I found it) as long as one doesn't mind an extra window popping up:

import java.awt.*;
import javax.swing.*;
public class BlatherApplet extends JApplet {
 public void init() {
  Blather canvas = new Blather(true);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.