HTML Tag | Comments |
---|---|
<applet | |
code="MyClass.class" | no qualification allowed. The name of the class file for the applet. Make sure the case and name exactly match the name of the *.java file, *.class file, and class name. |
width=330 | width of entire applet display in pixels |
height=240 | height of entire applet display in pixels |
archive="Everything.jar,Sub/MoreStuff.zip" | Resource file, classes etc. |
codebase="MyClassFileDirectory" | URL/directory where class files are, like a classpath. |
vspace=10 | pixel width of border above and below the applet |
hspace=10 | pixel width of border left and right of the applet |
align=left | how this applet aligns, treated like a image |
alt="Sorry no Java" | what to display if no Java interpreter available |
name="receiver" | Name for this applet so that other applets can communicate with it. Other applets would do a getAppletContext().getApplet("receiver") to get a handle on this applet. |
> | Note all that stuff above inside the <applet ... < |
<param name="favouriteColour" value="orange"> | The param statements are Java's ode to verbosity. They pass information to the applet. There can be as many param statements as you like. |
<img SRC="images/NoJava4U.jpg"> | image to display if no Java interpreter available. |
</applet> | and finally the ending tag for the |
import java.awt.event; // allow this applet to run as as application as well static public void main(String args[]) { final Converter applet = new Converter(); Frame frame = new Frame("Converter"); frame.setVisible(false); frame.setSize(330,240); applet.init(); frame.add(applet); frame.validate(); frame.setVisible(true); applet.start(); frame.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent e) { applet.stop(); applet.destroy(); System.exit(0); } // end WindowClosing } // end anonymous class ); // end addWindowListener line } // end mainYour applet can get hold of the parameters in the HTML. getParameter("favouriteColour") will return the String "orange". When you write an Applet often you will override some of the following methods: init(), start(), stop(), destroy() and paint(Graphics g). See application, aglet, servlet.
// note how you never specify the array's size in its type declaration. int[] v; // allocate space for the array v = new int[100]; for (int i=0; i<v.length; i++) v[i] = i*2+999;Here is how you would allocate an array of objects.
Cell[] v = new Cell[100]; for (int i=0; i<v.length; i++) v[i] = new Cell(i,999);You can initialise an array to a list of values this way:
String[] fruits = {"banana", "pear", "orange", null, favouriteFruit()};With JDK 1.1, you can assign an array to a list of values this way:
fruits = new String[] {"banana", "pear", "orange", null, favouriteFruit()};Methods can return arrays. The callee allocates the space for them.
String[] getFruits() { String[] s = new String[3]; // at this point s[i] is null not "" s[0] = "banana"; s[1] = "strawberry"; s[2] = favouriteFruit(); return s; }See matrix, gotchas under array.
![]() |
![]() |
![]() |
|
Canadian Mind Products | The Mining Company's Focus on Java Best of the Net Award |
You can get an updated copy of this page from http://mindprod.com/jglossa.html |