Solved

Applet and ClassLoader

Posted on 1997-08-22
1
320 Views
Last Modified: 2013-12-29
Is it possible to create an Applet which could load and execute Applets from another URL? I know about showDocument-method, but I would like to execute Applets in my own Applet's Frames. Is it possible to use some kind of ClassLoader class to do this?
0
Comment
Question by:Klaavu
1 Comment
 
LVL 4

Accepted Solution

by:
russgold earned 150 total points
Comment Utility
Only partially possible. You may load and execute another Applet as long as the other Applet is available in your applet's CLASSPATH.  Applet's are subclasses of containers, and may be treated as such.  Note that you cannot use a URL to do this, since URLs specify pages, not applets.

The problem is twofold. You can only access files of any kind - even via URL - if they come from your applet's home site.  But even then, your non-overridable ClassLoader is restricted to the CLASSPATH specified in your HTML <APPLET> tag.

Here is some sample code that works if you meet all the necessary conditions:

try {
    Class appletClass = Class. forName( "AnotherApplet" );
    Object anotherApplet = appletClass. newInstance();
    if (anotherApplet instanceof Applet) {
        appletContainer. add( anotherApplet );
        anotherApplet. init();
        anotherApplet. start();
        }
    }
catch( Throwable t ) {
    // handle ClassNotFoundException, InstantiationException,
    // and IllegalAccessException
    }

you will have to make sure that the applet's start() and stop() methods are called at the appropriate time.

Note: this
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now