The Study

home |  about

Programming

Introduction

Delphi

Java

Projects

Graphics

Introduction

POV-Ray

Terragen

Music

Introduction

Work in Progress

Oddments

Library

Miscellaneous

JavaDrivel Code

About JavaDrivel

JavaDrivel is, as you may have already guessed, a fairly pointless little applet. If you've looked at the 'edit' facilities you will have realised that it doesn't even make use of any clever artificial intelligence. In other words, it's just a bit of fun. I wrote it as a way of teaching myself how to write Java applets, and how to get them up and running on a web-page (which proved almost as difficult as writing the thing in the first place).

JavaDrivel contains one interesting class (in the sense that it might be useful outside of JavaDrivel) which is the 'scrolling canvas' that displays the output. I originally thought I would probably find that Java already contained a component to do something like this, but it turned out that it didn't, so I had to write my own. The class is called 'AutocueCanvas' (because it somewhat resembles the autocue used by television presenters). If you want to make use of it, you shouldn't find it difficult. There are two methods that you need to know about: clear(), which simply clears the canvas, and append(String text), which adds more text to the canvas. The text will be word-wrapped, and the canvas automatically scrolls if the bottom is reached. That's all there is to it. (Well, almost. See the source code and the documentation for more information, and for bugs, of which there are a couple!) Once I know more about it, I may turn the AutocueCanvas into a JavaBean. Watch this space!

Source Code

Ok, if you are interested in seeing the source code, you can download it from here. It comes in a .ZIP file, which includes documentation, and batch files (for Windows users) to compile the classes. You might need to edit the batch files to suit your own set-up, but hopefully they should work without any changes.

Return to JavaDrivel