Convert JFrame to JApplet

Hi

How can one convert his existing application which uses JFrames and a main method() to an Applet which extends JApplet and invokes init()?

Perhaps I could write a small applet which creates an instance of my application but my application uses it's own frames and GUI.How do I make them appear through the applets frame?

[357 byte] By [gperdikea] at [2007-9-26 1:17:46]
# 1

Hi qperdikea,

Yes, but the difference is not that important once you know what's going on. Applets are closely related to Panels and JPanels. They're all subclasses of Container and you can put one inside the other. The short answer is, make a JTree, put it in a JScrollPane to make it scrollable (use the constructor new JScrollPane( aJTree )), put that in a JPanel (use method add()), and use setContentPane() to make that JPanel the content pane for the JApplet. Or if you're using Applet, you can just use add(), I think.

So wherever they put something in a JFrame in the application example, you just put it in your JApplet instead and it ought to work. You can even make main still work as an application if you have main put a new

version of your applet into a JFrame and pack it and make it visible, etc. all the stuff that the example does with the Jframe.

I hope this will help you.

Thanks

Bakrudeen

bakrudeen_indts at 2007-6-29 0:47:49 > top of Java-index,Archived Forums,Java Programming...
# 2
Here are some steps to make the change between applications and applets...You can make the changes to adapt to swing http://www.ida.liu.se/labs/kplab/teaching/tddi48/1998/thumbprints/Applet/sld033.htmHop ethis helps...
pedro.garcia at 2007-6-29 0:47:49 > top of Java-index,Archived Forums,Java Programming...
# 3
Thanks guys.You've been helpful...
gperdikea at 2007-6-29 0:47:49 > top of Java-index,Archived Forums,Java Programming...