[ Main | Next ]

Evaluator Applet

The Evaluator applet lets the user enter values for one or more variables, and it displays the values of one or more expressions that depend on those variables. The display is updated continuously. If no applet params are specified, then there is one variable, named "x", and one expression, "log2(x)". Here is what the basic applet looks like:

Applet params can be used to specify the variables and expressions. There are also params for setting the colors used in the applet. Here is another version of the Evaluator applet that has been customized with applet params:

This applet was created using the applet tag:

   <applet archive="jcm1.0-config.jar" code="Evaluator.class" width=300 height=158>
      <param name="Variable1" value="x 1">
      <param name="Variable2" value="N">
      <param name="Expression1" value="e ^ x">
      <param name="Expression2" value="x ^ N / N!">
      <param name="Expression3" value="sum(i,0,N,x^i/i!)">
      <param name="BackgroundColor" value="red">
      <param name="LabelBackground" value="255 255 180">
      <param name="LabelForeground" value="180 0 0">
      <param name="AnswerBackground" value="200 200 255">
      <param name="AnswerForeground" value="blue">

Sometimes, instead of having the applet appear on the Web page, it's convenient to have it in a separate window. In this case, you can display a button on the Web page. Clicking the button will open the applet in its own window. For the configurable JCM applets, you can get this behavior by specifying a value for the applet param "LaunchButtonName" or more simply by specifying the height of the applet to be unreasonably small for an actual applet. For the Evaluator applet, a height of less than or equal to 35 will cause the applet to get its own window. Here's what you get if you change the height in the above applet tag to 35:

Here is a table of the applet parameters processed by the Evaluator applet. Keep in mind that you have to get the name of the param exactly right, including the capitalization. A color value can be specified as a list of three integers in the range 0 to 255. These numbers give the amounts of red, green, and blue in the color. Colors can also be specified using one of the standard Java color names black, white, red, green, blue, yellow, cyan, magenta, gray, lightGray, darkGray, pink, and orange. Note that param values are not case-sensitive. Expressions in this applet can use factorials and summations, even thought these are not defined in parsers by default.

Param Name Type Default Description
BackgoundColor Color gray The background color for the applet. This color is only visible around the edges of the applet and between the components that it contains.
LabelBackground Color 250 225 225 The background color for the labels on the left side of the applet.
LabelForeground Color 0 0 200 The color of the text in the labels on the left side of the applet.
AnswerBackground Color same as LabelBackground The background color for the values of the expressions.
AnswerForeground Color red The color of the text in which expression values are displayed.
InputBackground Color white The background color for the variable input boxes. (This is ignored by some versions of Java.)
InputForeground Color black The color of the text in the variable input boxes. (This is ignored by some versions of Java.)
FrameTitle String Calculator The title in the title bar of the window, when the applet is shown as a separate window.
LaunchButtonName String (none) If this is defined, then the applet will have its own window and only a button will appear on the Web page. The value of the param gives the label for that button. A separate window is also used even if this param is not defined but the height in the applet tag is less than or equal to 35. In this case, the label of the button is "Launch" followed by the value of the FrameTitle param. The size of the window is determined by its contents.
String x Names of input variables. If none are provided, there is one input variable named "x". The name of the variable can be followed by a space and an initial value for the variable. For example, the param value "N 5" specifies a variable named N with an initial value of 5. (By the way, variable values can be constant expressions such as "pi" or "sqrt(2)".) You can use the param Variable1 whether or not you have a param named Variable. However, you can't use Variable2 unless you have Variable1, you can't use Variable3 unless you have Variable2, and so on.
String log2(x) Expression that are to be evaluated. If none are provided, there is one expression, "log2(x)". You can use the param Expression1 whether or not you have a param named Expression. However, you can't use Expression2 unless you have Variable1, you can't use Expression3 unless you have Expression2, and so on.

[ Main | Next ]