aspose file tools*
The moose likes Applets and the fly likes Applet introspection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet introspection" Watch "Applet introspection" New topic
Author

Applet introspection

Angus Rose
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
Is it possible to load an applet into an application and use the reflection api in order to see what methods and attributes the applet conatins?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

Yes.


[Jess in Action][AskingGoodQuestions]
Angus Rose
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
Well thanks for the short and sweet reply. The next question is how?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

An applet is no different from any other object. You get the Class object for the applet class, then use the getDeclaredMethods() and getDeclaredFields() methods to investigate it.
Angus Rose
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
Can it be done on an applet that is currently running in a browser?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

Sure, by code in the applet itself, or by another applet on the same page if the target applet has the MAYSCRIPT="TRUE" attribute on the HTML page.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Applet introspection
 
Similar Threads
Applet with a ServerSocket
WA #1.....word association
Clock
Clock
Java program protection.