With providing a flexible and powerful "skeleton" framework for applets, the
developer has neither to "reinvent the wheel again", nor to transfer whole passages
of code for new programs. Instead, basing on an applet skeleton, mathlets have
a generic interface for both the code itself and the placement of code. This
simplifies the understanding of mathlet code (even if it is not the "own" code)
and thus reduces developing and debugging time.

Structure of a mathlet

The class BaseApplet is the base for all mathlets. It defines a common design
where the components are placed into predefined panels/panes (containers able
to hold GUI-components). The 3 main panels of a mathlet are (read from top to
  • title pane containing a text panel with the mathlet’s title
  • center pane containing the canvases and/or a control-panel
  • button pane containing the help, reset, screenshot and animation buttons
    The center pane itself is divided into (from top to bottom)
  • canvas pane containing a single canvas or an arrangement of several canvases
  • controls pane pane containing a ControlPanel

The choice of a mathlet type

The mathlet-class needs to extend one of the template classes below. There are
mathlet template types for the most common needs. The main distinction of
theses templates is made by the number, the arrangement and the dimension of
their canvases. The following template types are available:
  • "No-Canvas" – only 1 ControlPanel: NoCanvasApplet
  • "Single" – 1 single canvas and 1 ControlPanel below: 2D : SingleG2DCanvasApplet, 3D : SingleJ3DCanvasApplet
  • "Side-By-Side" – 2 canvases arranged horizontally and 1 ControlPanel below: 2D : SideBySideG2DCanvasApplet, 3D : SideBySideJ3DCanvasApplet
  • "Upper-Lower" – 2 canvases arranged vertically and 1 ControlPanel below: 2D : UpperLowerG2DCanvasApplet
  • "Upper-Middle-Lower" – 3 canvases arranged vertically and 1 Control-Panel below: 2D : UpperMiddleLowerG2DCanvasApplet

The ControlPanel resides below the canvases, except for the NoCanvasApplet: there it covers the whole mathlet’s space.

Creating the applet class

The "entry point" of every applet is the init() method which will be called by the web-browser to load and initialize the applet.
This is also true for a mathlet and its runtime: a call to the init() method of the super class is necessary for initializing the system.
An empty mathlet can look like this (e.g. for a "Single-Canvas"-applet):

import net.mumie.mathletfactory.appletskeleton.g2d.*;

public class MyApplet extends SingleG2DCanvasApplet {
  public void init() {
    super.init(); // needed to initialize the runtime
    ... // your entry point

Note that the call super.init() is needed to initialize the mathlet’s runtime.

Add picture from clipboard (Maximum size: 500 MB)