Reputation: 95
as the title says, I want to place a JApplet within a JPanel, because I'm making a plugin that is supposed to show a biological diagram. The Applet itself has already been written and I've also already made a HTML tag, which also works in a browser. However, I don't know how to get the applet to run within the JPanel
HTML tag:
<applet name="Spectrum_a" code="org/openscience/nmrshiftdb/spectrumapplet/SpectrumViewNoRenderer.class"
codebase="/home/rianne/workspace/org.pathvisio.MetaboliteInfo/lib/"
archive="spectrumapplet-bin-1.1.jar" width="450" height="350">
<param name="spectrum" value="197.74d;0.0;1|143.55;0.0;0|27.36;0.0;2t|">
<param name="realisticLines" value="true">
<param name="showCoupling" value="true">
<param name="hideNavigation" value="false">
<param name="autoIntensity" value="false">
<param name="solvent" value="CDCL3">
</applet>
Hope someone can help me:)
Upvotes: 1
Views: 83
Reputation: 60858
To embed an applet into a Java application, I'd advise against using HTML. Instead, treat the applet as a simple component, and try to behave like a browser plugin towards the applet. In particular, make sure to set a stub and call the init
and start
methods appropriately. It is that stub which provides parameters to the applet, so by implementing the getParameter
method appropriately, you can pass whatever parameters you desire.
You might have to create a separate class loader for the jar of the plugin, and instantiate the plugin class through that class loader. If your environment doesn't allow your plugin the creation of new class loaders, then you should list the applet jar as a dependency of your plugin, so that its classes are available in the same class path your plugin uses. Doing so might be the easier route even if you're allowed custom class loaders, so choose whatever approach you prefer.
Upvotes: 4