Detect Applet context (am I inside an applet?)

Posted by 7macaw on Stack Overflow See other posts from Stack Overflow or by 7macaw
Published on 2010-03-18T16:32:44Z Indexed on 2010/03/18 17:11 UTC
Read the original article Hit count: 673

Filed under:
|
|

Hi,

I'm wondering if there's a way for a Java class to figure out if it is being used within an applet?

That is, I have a library (a .jar file) that can be used by 3rd-party applications and applets. It does work within applets, but I'd like to do some things differently, depending on whether or not the library is used in an applet - like show applet-applicable errors, avoid local file I/O, etc.

It would be nice if, say, Applet.getAppletContext() was static so that I could call it (and get NULL or not NULL) even if I don't have an applet instance, but alas, it isn't. Is there any other way?

© Stack Overflow or respective owner

Related posts about java

Related posts about applet