Can I load an applet dynamically into a Java application, and if so, how does the applet get the parameter information it would normally get from the APPLET tag?
Ans : Applets can be loaded into Java applications like other user-interface elements, but you must use care to provide them with the connections and support they normally expect to receive from a web browser. Applets are a subclass of Panel, which in turn is a subclass of Component – the base class for all Abstract Window Toolkit (AWT) user-interface elements. In terms of building an interface, you can add an applet to a panel or window/frame just the same as you would a button: Applet myApplet = … Panel p = new Panel(); p.add(myApplet); p.add(new Button(“Press me.”)); Applets generally require much more care, though, in how they are hooked up to the rest of the application. For an application to provide a general framework for linking in applets, it must provide objects that implement the AppletContext and AppletStub interfaces. (Note that one class can implement both interfaces.) For example, in the JDK (1.0.2 and 1.1), an applet call to getParameter gets relayed to an AppletStub
Related Questions
- Can I load an applet dynamically into a Java application, and if so, how does the applet get the parameter information it would normally get from the APPLET tag?
- Id like for my applet to load my own custom version of a core Java class, like java.lang.String. How can I do this?
- What is the difference between Java applet and Java application?