Applets
In Visual Studio, select menu item
, highlight Java Applet, give it a name then click the OK button. This gives you a default applet from which to start. You can also paste code into the default project to run demonstrations. Note that namespaces comprise lower-case letters only. We provide several examples of short project files that you can use to compile applets using the command-line compiler.The output of compilation of applets is a jar (Java archive) file. There is a tool named jar in the Java SDK that you can use as follows.
- jar tvf MyClasses.jar lists the contents of MyClasses.jar.
- jar cvf *.class makes an archive of all the .class files in the current folder.
- jar xvf MyClasses.jar Main.class extracts Main.class from the archive.
To run applets in HTML files you need a web browser that can be Java-enabled. You might be able to use the appletviewer in the Java SDK by supplying it with the URL of the web page containing the applet.
An Applet inherits many useful methods from java.awt.Component e.g. addKeyListener addMouseListener, addMouseMotionListener, getHeight, getWidth, getSize, setBackground, setFont, setForeground. Be on the lookout for these methods when reading the source code of the examples.
We are grateful to Dharmesh Tailor for converting ten of these applets from the original Java code and for writing an effective demonstration himself. You can see screenshots of the original applets at Professor Michael McGuffin's new site. (Brian Long's conversions of a few of these applets are included in the download of Oxygene for Java from RemObjects).