HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML

"Applet Customizers"
Vol. 2, Issue 3, p. 42


Listing 1: The CustomizerForHTML interface

import java.util.Properties;
import java.applet.*;

public interface CustomizerForHTML extends AppletStub {
    // Sets the applet, base stub and context
    // for this CustomizerForHTML.
    public void setAppletAndAssoc(Applet a, AppletStub as,
            AppletContext ac);
    public Properties getAppletParameterSettings();

Listing 2: Excerpts from the AnimatorCustomizerForHTML class

import java.applet.*;
import java.awt.*;

public class AnimatorCustomizerForHTML implements CustromizerForHTML {
    // State variables
    private AppletStub m_baseStub;
    private AppletContext m_context;
    private Properties m_params = new Properties();
    private Applet m_applet;

    // Public default constructor, required.
    public AnimatorCustomizerForHTML() {}

    // Set the applet, stub and context
    public void setAppletAndAssoc(Applet a, AppletStub as,
            AppletContext ac) {
        m_applet = a;
        m_baseStub = as;
        m_context = ac;

    // Gets the list of parameters and values set by the user.
    public Properties getAppletParameterSettings() {
        return m_params;

    // The only overridden AppletStub method is getParameter.
    // The rest pass thropugh the call to the m_baseStub AppletStub.
    public String getParameter(String p) {
        return m_params.getProperty(p);

    // This method is called by event handling code when user,
    // through UI, changes a parameter's value. The only way
    // to get the applet to properly reflect the new property
    // value is to stop, destroy, and re-init the applet. I
    // know it's based to re-init applets, against spec and all.
    // a more complete solution is beyond the scope of this column.
    public void setParameter(String param, String val) {

        Properties.put(param, val);


    // Event handling code has been omitted for space reasons.
    // The pertinent code for this class is above.



All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.