<Swing Dev> Reinitializing an Applet

Johannes.Lichtenberger Johannes.Lichtenberger at uni-konstanz.de
Tue Jan 17 12:16:30 UTC 2012


On 01/17/2012 11:49 AM, Pavel Porvatov wrote:
> Hi Johannes,
> 
> It's hard to imagine what methods (like mEmbed.dispose()) do. Could you
> please provide a small test that can be run and which shows the problem?

Hello Pavel,

maybe [1] helps clarifying some issues. mEmbedded is an instance of
PApplet which extends Applet. I'm just embedding it into a JPanel or
JScrollPane instead of directly in a JFrame.

Now I want to create a new instance of the embedded Applet but at first
dispose the currently running applet (and thus the running Animation
Thread which is started from the PApplet (processing)).

At the time it somehow messes up as I'm creating a new embedded
instance, a new PApplet/Applet instance. I think the problem is how I
can dispose or destroy an instance and bind a new instance to mEmbedded.
In the first place everything works fine (except the
heavyweight/lightweight issue if I'm inserting the (P)Applet into a
JSplitPane on one side. Other than the the applet is initialized
properly and the heavyweight vs. lightweight issue also doesn't appear
when I'm adding the applet to a JPanel or JScrollPane which is added to
another JPanel which then is added to a JFrame instead of adding the
JPanel/JScrollPane to a JSplitPane. I think the JSplitPane has somehow
issues with heavyweight vs. lightweight components.

Other than that I suppose it boils down to how I can safely reinitialize
an Applet/bind the variable to a new Applet.

First nulling the mEmbedded instance doesn't work either, the new
instance somehow gets messed up and the JMenuBar is greyed out which is
added to the parent JFrame.

Within a JScrollPane however it's working with setViewPort(mEmbedded),
to the new instance, maybe the revalidation(), repaint() is not correct.

kind regards,
Johannes

[1]
http://processing.googlecode.com/svn/trunk/processing/build/javadoc/core/processing/core/PApplet.html




More information about the swing-dev mailing list