NCSAHabanero

[ Previous ] [ Index ] [ Next ]

-------------------------------------------------------------------
What to change first to habanerize an applet
-------------------------------------------------------------------

Change superclass, imports, and initialization

Background Information

Because hablets need to run simultaneously on many different machines, there are some things you need to change in your applet to make it into a hablet.

How does this work?

So that Habanero and Java can find the files without your needing to add their location to the CLASSPATH, you need to pick a package name and indicate it at the start of every .java file for your hablet. In the directory you installed Habanero, there is subdirectory called apps. Make a subdirectory of apps with the same name as the package name and copy all your source files there.

When you copy the applet java file, we suggest you change the name of the applet class (perhaps by adding "Hab" as a prefix) to avoid class name confusion. Your original applet file remains unchanged so that you can still run it as a single-user applet.
 
Running Example from the example of habanerizing TextDemo.java.
To start the Running Example, create a subdirectory of apps called TextDemo. Copy TextDemo.java there and rename it HabTextDemo.java. Then put at the top of the file: 

package TextDemo;

 
Along with the standard imports of :

you need also to:  
Running Example from the example of habanerizing TextDemo.java.
Just add to the imports: 
import ncsa.habanero.*;
import ncsa.habanero.streams.*; 
import java.io.IOException;
 
Change the superclass from Applet to Hablet:
 
Running Example from the example of habanerizing TextDemo.java.
public class HabTextDemo extends Hablet
 
 
NOTE

If you are converting an applet into a hablet, you always have to change the superclass as indicated above. Applets have a lot of data, such as window information, that you do not want to be transferred to other running copies. Hence when you subclass from Hablet instead, we prevent that information from being copied. If you are not starting from an applet -- for example, if you start from an application -- you will not have to do this. 

What next?

  1. Specify the default Window parameters.
  2. Write methods to transfer the state of the current hablet to other instances of the hablet in other sessions.
  3. Take care of Event Handling.
  4. Install your new hablet into your Habanero environment.


Habanero® is a registered trademark owned by The Board of Trustees of the University of Illinois. Copyright 1996-1998. All rights reserved.   Java(TM) is a proprietary trademark owned by Sun Microsystems, Inc. NCSA
The National Center for Supercomputing Applications

University of Illinois at Urbana-Champaign

Contacts page