Deliverable
By the deadline you should have at least one
original Java applet on a HTML web page with link to the source code.
I hope this will be a public web page that is
linked to your CS320 web page. I expect the code to
include some thing original... and your page to have notes saying what is new
about it.
You page should also have a paragraph or picture that defines the relationship between these classes: Throwable, Error, Exception, RuntimeException, and IOException.
Process
Start from with my existing Java and HTML samples.
Modify them.
You may have to take classes and extend them to do what
you'd like them to do. You can(probably will) implement existing interfaces and abstract
classes. Add comments indicating what you changed.
Study the examples and experiments below. Pick one. Download the page and source code into your working directory and make changes. When done put the test page, the source code, and the compiled applet in your public web site(below). Find the index page and add a link to it to your Java page.
import ColoredText;does not seem to be compatible with all versions of Java. Very old and newer ones automatically import local classes so I had to make it into a comment:
//import ColoredText;You may hit a Java where it has to be uncommented.
By drawing a UML diagram or in text describe the hierarchy of
Throwable classes.
Concurrency
Here is the same applet running only one thread: [ test.Spinner.html ]
Warning: close down and reopen your browser after running the second one above.
For more on Thread see [ Thread.html ]
CPU Eaters
Java has a nasty little flaw: it is inherently multithreaded.
On the other hand if you avoid Threads you tend to get blank
images:
Worse several browsers do not allow you control of these thread. If you look at a page with an Applet that has a thread that doesn't stop itself it will continue running after you leave the page. Slowly and steadily as you view badly behaved applets your CPU gets full of things you can not see or control. The cursor flickers, and so on.
It would be unethical for me to show you a demonstration page! I have perpetrated this kind of problem in some of my code. The following shows a program that shows a blank when run as an application and grabs the CPU if run in a browser: [ Surat2.java ]
For more see, [ mbox ]
. . . . . . . . . ( end of section Concurrency) <<Contents | End>>
More Java
More Layouts
You may need or want to do some sophisticated graphic interfaces
if so this experiment may help you.
A layout manager automagically places some graphic parts inside a larger graphic Container. Here is an example of some of the standard layouts.
By the way take note of the relation
instanceofin the CardTest code it allows Java to find out the type of an object at run time.
A Graphic Applet
Java is one of the few languages to provide the functionality needed
to graphics as part of its standard library. Previous languages have
left it up to others to create libraries for doing graphics. Dr.
Zemoudeh has a nice example of this in the Scribble applets and
applications. The source code for an application is in
[ StandaloneScribble.java ]
and the compiled byte-code file
[ Scribble.class ]
Try this out at
[ Scribble.html ]
Graphic Recursion
Here is a page+applet that uses the Le Riche algorithm to plot
a curve. I've used the Henrici spiral as a test case.
[ test.RecursiveHenrici.html ]
Try it out and then modify the curve (leave Le Riche
alone!).
Entropy and Randomness
Here is a page that demonstrates how to get Random Numbers
[ test.HowRandom.html ]
by painting 4000 random points. Here are a some more
[ test.Surat.html ]
that produce more or less random pointilist paintings.
George Seurat's real paintings are much better than these.
And his name is better when spelled write.
I'm still developing the following one. On some Browsers you have to reload to get the display to update:-) [ test.Surat4.html ]
. . . . . . . . . ( end of section More Java) <<Contents | End>>
. . . . . . . . . ( end of section CS320: Java Applets) <<Contents | End>>
Check the Preparation for next class
[ ../18.html ]