| Applet Drawing Library: adraw.jar | |||||||||||||||||
The Javadocs for the adraw library. The
To convert the The The The
// Relevant parts of the WorldApplet class:
abstract public class WorldApplet extends JApplet{
protected int WIDTH;
protected int HEIGHT;
abstract public World getNewWorld();
abstract public void setWorldSize();
}
The applet is now ready to run and can be shown in AppletViewer when run as an applet from the current IDE or from the command line. An applet code and the Before we can write the For the first option, every jar file must be saved in a directory whose name matches the name of the package to which the file belongs. If the xlib.jar file belongs to a package with the name mylib.util then we must create in the MyApplet a subdirectory sequence MyApplet/mylib/util and save the xlib.jar file in this directory. For the JavaLib packages we need to build the following directories (and files in them): MyApplet/adraw/adraw.jar, MyApplet/colors/colors.jar, MyApplet/geometry/geometry.jar, and MyApplet/tester/tester.jar, if it is used (the test code may be deleted from a published applet - for brevity.) For the second option we only have to know the URL for a location where the library files are accessible. Make sure this is a permanent depository that will not disappear in a couple of months. Also, if the files stored at the URL location are likely to change and you worry that your applet may no longer be compatible with the updated version, you may decide that option one is a better choice for you. The permanent website for these libraries is located at the following URLs:
New releases will be saved in directories with new version numbers. We present four different ways for uploading the applet source code:
The applet can be presented as a standalone web page, or as a part of a collection of applets, or can be embedded in a web page with other contents. Edit the html code at the end of this section with information specific to your applet at all places shown in italics. Provide directions for the user that explain how to play your game, or how to use your world. Specifying where the browser can find the applet source code.The line code="MyWorldApplet.class" indicates that the class For the four options for how to save your source code described above we provide sample code for locating the source code within the applet html file:
The next part tells the web browser where to find the .jar files, i.e. the libraries and possibly the .jar file for the applet source code.
archive="myworld.jar,
./adraw/adraw.jar,
./geometry/geometry.jar,
./colors/colors.jar"
Omit the part myworld.jar if you have saved your code as .class files (see above). If you wish to refer to archival library collection at a specific web site, you may write:
archive="http://www/some-server.abc/adraw/adraw.jar,
http://www/some-server.abc/geometry/geometry.jar,
http://www/some-server.abc/colors/colors.jar,
http://www/some-server.abc/tester/tester.jar"
or specify some other web site where your libraries are found. The last part of the applet tag in the html file gives the total size of the applet. The size given here is the size of the border around your world - make is at least 20 pixels bigger than the size given in the Java code. Save the file as MyAppletWorld.html in the MyApplet directory. Access the applet on the web at URL http://www.myname.net/MyApplet/MyAppletWorld.html Sample complete html file:
<html>
<head>
<title>
Web page title: My applet
</title>
</head>
<body>
<h2> My Applet Header</h2>
<p>This is how you play my game.
Please, use the slider to set the clock speed
before starting the game.</p>
<applet
code="MyWorldApplet.class"
archive="myworld.jar,
./adraw/adraw.jar,
./geometry/geometry.jar,
./colors/colors.jar"
width="400"
height="400">
</applet>
<hr></hr>
... additional webpage contents ...
</body>
</html>
Directory structure The directory structure for this applet looks as follows:
MyAppletFolder ... the main applet folder
MyApplet.html ... the html file defined above
myApplet.jar ... a jar file that contains
MyWorldApplet.java,
MyWorld.java,
and all other files my world uses
adraw ... a subdirectory
adraw.jar ... the Applet world library
geometry ... a subdirectory
geometry.jar ... the geometry library
colors ... a subdirectory
colors.jar ... the colors library
| ||||||||||||||||||
| last updated on Fri Apr 1 14:26:43 EDT 2011 | generated with DrRacket |