This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes How can I diplay and Applet on a swing application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "How can I diplay and Applet on a swing application?" Watch "How can I diplay and Applet on a swing application?" New topic
Author

How can I diplay and Applet on a swing application?

Femi Alla
Ranch Hand

Joined: Jul 05, 2002
Posts: 79
Greetings everyone,

I found myself in a quiet unusual situation. I need to display an applet on a JPanel. But can't seem to figure out how to go about it, or it would be possible at all. I kind of think this should be possible since Applet is a subclass of Panel.

I'm would like to display the Applet on a JPanel, which is part of a JTabbedPane and I don't know how I can go about doing so.
I attempted trying to take swing components ability to display HTML a little futher but it didn't work.
Since something like this is possible:


I created a Panel and made it contain only one label , which would be displayed when the appropriate tab is clicked. Now the label contained HTML but with the applet tag. [Dont laugh!. Didn't know what else to do. ]

Here:



But then at runtime, I got all the exceptions:



This is making me to think that my solution lies in the javax.swing.text.html, and the javax.swing.text packages. If this is so, is anyone familiar with these packages, or does anyone have any idea how I could
achieve what I want to achieve?

Any useful suggestions would be appreciated.

Thanks so much.


SCJP
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
If your applet is an AWT applet it won't work. If it's a JApplet okay. Here's one way to do it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How can I diplay and Applet on a swing application?
 
Similar Threads
When I reload the applet the labels with html syntax hides.
Granting Security Policy Permissions
Applet question
Unicode in Swing ?
Why dont this work?