VBScript and Java Applets


considerably different. Java applets are programs created in Java that are then generated in a platform-neutral byte code format. These bytes are not specific to a UNIX workstation, a pc, or an Apple Macintosh but remain in a general, predefined form that cannot be directly executed by a computer. How does an applet ever run? You can download a Java applet with a page as a separate file, and then a browser can launch that Java applet through a piece of software called a run-time interpreter. This run-time interpreter translates the generic byte codes of the applet file into specific actions executed by the computer. The third form of Java is a Java application. A Java application is like a standard application. It is generated in the byte format understood by a computer type. It can then run directly on computers of that type with no additional translation.

You can integrate the applets into your programs and directly use their capabilities from your script. It's very much like the ActiveX object integration model. There are some differences, such as the events that ActiveX provides, but there are also a lot of similarities. You incorporate a Java applet through an object definition. You provide a name for it that you will reference from your code. You interact with it through the properties and methods that it has defined. An applet can show up on the page as a visible component that the user sees and interacts with.

A listing below shows a sample of a Java applet object declaration. The applet an analog display which you can modify by changing the color of the background, hands and numbers. Your script will be able to reference this Java applet object by the name myApplet because that is the name assigned through the name attribute. The code attribute indicates the class name of the Java applet, which is JavaClock

<applet name="myApplet" codebase="classes"
code="JavaClock.class" width="150" height="150">
<param name="delay" value="100">
<param name="link" value="http://java.sun.com/">
<param name="border" value="5">
<param name="nradius" value="80">
<param name="cfont" value="TimesRoman|BOLD|18">
<param name="bgcolor" value="ddddff">
<param name="shcolor" value="ff0000">
<param name="mhcolor" value="00ff00">
<param name="hhcolor" value="0000ff">
<param name="ccolor" value="dddddd">
<param name="ncolor" value="000000">
</applet>

As you can see, the declaration approach is very much like that used for other controls. Using a Java applet object from code is even more similar. Code that uses the applet is given below. This code is a subroutine and  can be executed in response to some action, for instance, by clicking on the page. The code changes the background

The copyright of the article VBScript and Java Applets in VB Script is owned by Maxim Karetnikov. Permission to republish VBScript and Java Applets in print or online must be granted by the author in writing.

Go To Page: 1 2 3

Articles in this Topic    Discussions in this Topic