Home : Course Map : Code Index
JavaTech Programs & Code Index
JavaTech
Course Map
     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

Here we provide an index to the programs and source code developed for this web course. This includes a number of starters that we used as the initial code for many of the programs.

Program List as of Sept. 20, 2005

Part 1: Java
Ch Course Page
Class Source Code Description
1

Demo 1: HelloWorld  

HelloWorld

Simple demo to show basics of creating an applet.
Demo 2:
A Simple Java Application

HelloWorldApp Simple demo to show how to create an application program and print to console.
2 Demo: Print to Console

ConsolePrintApplet1
ConsolePrintApp1

Demonstrates basics of string concatenation and automatic conversion of numbers for printing to console. Applet version prints to browser console from the applet's init() method.
Application prints from main() method.
3 Demo 1a: Creating Objects: Data Fields DataFieldApplet
DataFieldApp
Applet and application programs that illustrate the data fields in a class definition.
Demo 1b: Creating Objects: Methods MethodApplet
MethodApp
Applet and application programs that illustrate a method in a class definition.
Demo 2: Constructors

ConstructorsApplet
ConstructorsApp

Illustrates the two different ways to instantiate a class with two constructors.
Demo 3: Static Properties StaticApplet
StaticApp
lIlustrates how a static property can be accessed before an instance of the class is created. Also if that static variable is changed, it changes for all instances of that class.
Demo 4: Value vs Reference

ValRefApplet
ValRefApp

Looks at the passing of primitive values and references in method arguments.
Demo 5: Overloading OverloadApplet
OverloadApp
Illustrate overloading of a method.
Demo 6: Wrappers WrapperApplet
WrapperApp
Demonstrates use of some of the wrapper class methods. For the applet version, an integer and boolean strings pass to the applet via the tags.
Demo 7: AutoBox/Unbox BoxApplet
Box
Demonstrates conversions to and from primitive types and their corresponding wrapper classes using the autoboxing and unboxing capabilities added with J2SE5.0.
Demo 8: Arrays ArrayApplet
ArrayApp
Demonstrates creating, initializing, and using arrays of primitive type values.
4 Demo 1: Inheritance InheritanceApplet
InheritanceApp
Illustrate the basics of a class extending another and of a class heirarchy.
Demo 2a :
Overriding & Overloading
OverrideApplet
OverrideApp
Use an array to reference a class and its sub-classes to illustrate the polymorphic qualities of object methods.
Demo 2b :
Overriding & Overloading
RideLoadApplet
RideLoadApp
Illustrate both overloading and overriding with a class and its subclasses.
Demo 3: Constructors ConstructApplet
ConstructApp
Illustrates this() and super() and which constructors of subclasses and the class are chosen.
Demo 4: Interfaces InterfaceApplet
InterfaceApp
Two classes implement an interface. The primary class creates an array of such interface types and invokes the interface method overriden by the classes.
5 Demo 1 Packages
TestABApplet
TestAB
mypack/TestA
mypack/TestB
Illustrate the use of classes in a package.
Demo 2: Import

TestABCApplet,
TestABC

Illustrate use of import.
Demo 3:
Jar Files for Applets
TestABCApplet Same applet code as above but put into a jar. (TestABCApplet.jar)
6 Demo 1: Containers SwingButtonApplet Simple demo of adding a JComponent subclass, here a JButton, to the content pane.
  Demo 2:
Swing UI Components
ButtonsPanelApplet Illustrate adding multiple UI components to a panel in Swing.
Demo 3: UI Layout InputsPanelApplet, InputsPanel Use a JTextField and JLabel component in a UI along with a JPanel subclass.
Demo 4: UI Layout MultiPanelApplet Illustrates how to build up a complex UI with multiple sub-panels, each with their own components and panles if needed, within an overall panel.
Demo 5: Text Display TextOutputApplet
Outputable
TextOutputPanel
Create a JPanel subclass TextOutputPanel to display text. TextOutputPanel implements the Outputable interface, which has two "print" methods. GUI programs can then use TextOutputPanel to "print" messages to this panel rather than to the console.
Demo 6: Drawing DrawApplet
DrawingPanel
Illustrate basic drawing in a Swing applet. Create a JPanel subclass on which to do the drawing.
Demo 7: More Drawing

SimpleDraw2Applet,
DrawingPanel
Circle

This applet illustrates additional drawing techniques and some object design. "Circle Objects are sent to be drawn on the DrawingPanel, a subclass of JPanel.
Demo 8: Drawing Polygons Polygon1Applet
Polygon1Panel
This applet displays the Polygon1Panel, which uses an array of points and drawPolyline in Graphics to draw a polygon.
Demo 9: Drawing Polygons Polygon2Applet
Polygon2Panel
Similar to the previous demo except that a Polygon object is create and it is drawn.
Demo 10: Drawing Text DrawTextApplet DrawTextPanel Use the draw methods in Graphics to draw text on a panel.
Demo 11: Images ImageApplet
DrawingPanel

Illustrate how to load an image into an applet and how to draw the image.
Resources: liftoff.jpg
7 Demo 1:
Button Event Handling
PlainButtonApplet Illustrate event handling with a 2 buttons that send message to the browser status bar.
Resources: duke.gif, dukeWave.gif

Demo 2:
Button Event Handling

MultiPanelWithEvents ActionButtonsPanel InputsPanel Add event handling to the multi-panel demo in the previous chapter.
Demo 3: Mouse Listener CaptureEvtApplet
CaptureEventPanel

Moving the cursor into the CaptureEventPanel generates various mouse events, descriptions of which are displayed in a second panel.

Demo 4:
More Swing Components
CheckBoxesPanel UiTestApplet
OutputPanel
Three checkboxes are used to select the color of the OutputPanel.
Demo 5:
More Swing Components
RadioButtonsPanel
UiTestApplet
OutputPanel
Radio buttons are used to select the color of the OutputPanel.
Demo 6:
More Swing Components
ListPanel
UiTestApplet
OutputPanel
Select colors from a list for the OutputPanel.
Demo 7:
More Swing Components

SliderPanel
UiTestApplet
OutputPanel

Use sliders to select from a wide range of colors for the OutputPanel.
Demo 8:
Layout Managers-1
FlowApplet
FlowPanel
Illustrate laying out components with a FlowLayout.
Demo 9:
Layout Managers-1
BorderApplet
BorderPanel

Illustrate laying out components with a BorderLayout.
Demo 10:
Layout Managers-1
GridApplet
GridPanel

Illustrate laying out components with a GridLayout.
Demo 11:
Layout Managers-1
GridBagApplet
GridBagPanel

Illustrate laying out components with a GridBagLayout.
Demo 12:
Layout Managers-1
SpringApplet
SpringPanel
Illustrate laying out components with a SpringLayout.
Demo 13:
Layout Managers-2
BoxLayoutApplet
BoxPanel

Illustrate laying out components with a BoxLayout.
Demo 14:
Layout Managers-2
BoxApplet
Illustrate laying out components with a Box container.
Demo 15:
Layout Managers-2
BoxSpacingApplet Illustrate laying out components with a Box container and use Box Glue & Struts
Demo 16:
Layout Managers-2
CardApplet
CardPanel
Illustrate laying out components with a CardLayout.
Demo 17:
Layout Managers-2
TabbedApplet
Tabs
Illustrate laying out components with JTabbedPanes .
Demo 18:
Adapter Classes
AnonListenerApplet Demonstrate the use of an anonyomous listener object.
Demo 19:
Adapter Classes
AdapterApplet Demonstrate the use of an MouseAdapter
Demo 20:
Menus & Frames
FrameApplet Demonstrates the basics of creating a frame user interface with a menubar. It also shows how to add a menubar and dropdown menus to the applet, which wasn't possible in the basic AWT heavyweight component.
Demo 21:
Menus & Frames
FrameAppApplet This program can run either as an applet or an application. It displays an image on a JPanel object added to a frame.
8 Demo 1: Intro to Threads MyApplet
MyThread
MyClass1
Demo of threading with a Thread subclass.
Demo 2: Intro to Threads MyRunnableApplet Demo threading with Runnable implementation.
Demo 3: Animations SimpleAnimationApplet Simple animation using a Runnable implementation.
Demo 4: Animation Demo: Digital Clock ClockApplet
DataFormatPanel
This applet implements Runnable and uses a thread to create a digital clock.
Demo 5: Aimation Demo: Dropped Ball DropApplet
DropPanel
This applet implements Runnable and uses a thread to create a simple dropped ball demonstration.
Demo 6:
Non-interacting Threads
NonInteract
Outputable
This demo applet creates three instances of the IntCounter thread subclass, each of which will do an independent calculation. Illustrates how threads can do parallel (or apparent parallel on a single processor) processing via threads. Output of the thread goes to the text area on the applet interface. The applet implements the Outputable interface.
Demo 7: Task Splitting TaskSplitApplet
MatHunter

Outputable
Count the number of non-zero elements in a matrix byassigning instances of the MatHunter Thread subclass to search each quadrant.
Demo 8:
Exclusive Thread Operations
ExclusiveApplet
Box
Getter
Filler
Outputable

This demo applet illustrates synchronization with the Filler thread trying to fill the bin in the Box object and the Getter thread trying to get the value from the bin. The Filler must wait if the bin already is full while the getter must wait if it is empty.

Output of the thread goes to the text area on the applet interface. The applet implements the Outputable interface.

Derived from Java Tutorial Cubbyhole/Producer example.

Demo 9: Talking Threads DataSyncApplet.
Sensor
DataGetter
Outputable
Simulate a situation where a sensor puts data into a buffer and a data reader picks data from the "bottom" of the buffer.
9 Demo 1:
Text Output to Console
PrintWriterApp
Demonstrate stream wrapping by writing text to the console using the standard output from System.out wrapped with OutputStreamWriter and PrintWriter.
Demo 2:
Formatter Class and printf() - J2SE5.0
FormatWriteApp Demonstrate the java.util.Formatter capabilities for formatting primitive types.
Demo 3:
Input Text from Console
BufferedReaderApp Demonstrate the BufferedReader class for wrapping a reader object and providing the readLine () method.
Demo 4:
Using Scanner for Input from Console
ScanConsoleApp Demonstrate the Scanner class for input of numbers.
Demo 5: Text Output to FIles PrintWriterFileApp Demonstrate wrapping streams to send text and primitive * type values to a file.
Demo 6:
Formatter Output to File
FormatWriteFileApp Demonstrate the java.util.Formatter capabilities for formatting primitive types and sending them to a file.
Demo 7:
Text Input from a File
TextFileReadApp Demonstrate reading text from a file.
Demo 8:
Using Scanner for Input
from a File
ScanFileApp Demonstrate using Scanner to read a file.
Resources: textOutput.txt
Demo 9: File Binary I/O BinOutputFileApp Write a primitive type data array to a binary file.
Demo 10: File Binary I/O BinInputFileApp Demonstrate reading primitive type values from a binary file.
Resources: numerical.dat
Demo 11:
JFileChooser Dialog
FileChooserApp Demonstrate the use of a JFileChooser to open and save files. The chooser filers for .java files. Opening the file results in the text fillig a JTextArea component. The text can be modified and saved to a new file.
Demo 12:
Character Encoding
UnicodesApplet Simple Unicode demo program.
Demo 13:
Character Encoding
UnicodeFontsTables An applet to display the character tables as a function of text character and as function of Unicode value.
10 Demo 1: Preferences PrefsDemo
README.txt
build.bat, clean.bat,
run.bat

Simple demonstration of the most common usage of the Java Preferences API using the user and package based storage node. This app uses the user tree to avoid collisions with other users and uses the package name, as is conventional, to avoid collisions with other applications in other packages.

We include the standard accessory files that one should include when distributing files. Here README.txt describes the program and gives instructions on how to use the files. The Window .bat command files go as follows: build.bat does the compilation, clean.bat removes the class files when no longer needed, and run.bat executes the program.

Demo 2:
Calendars, Dates, & Time
ClockTimer1
DataFormatPanel
DateFormatPanel is a JPanel subclass that uses the DateFormat class to display the current time.
Demo 3:
Calendars, Dates, & Time
ClockTimer3
SimpleDataFormatPanel
This JPanel subclass uses the SimpleDateFormat class to display the current date and time. The ClockTimer3 uses java.util.Timer with an instance of a java.util.TimerTask subclass to generate the periodic clock update.
11 Demo 1:
More about Image Loading
ImageObsApplet
DrawingPanel
Illustrate use of ImageObserver for image loading.
Resources: 07-JG-01-pan-A074R1_br2.jpg
Demo 2:
More about Image Loading
MediaTrackApplet
DrawingPanel
Illustrate use of MediaTracker for image loading.
Resources: m20.gif
Demo 3:
Pixels and Transparency
TransparencyApplet
BgControlPanel
FgControlPanel
OutputPanel
Demonstrate effect of the alpha transparency factor in pixel values. The user selects via the BgControlPanel a color for a large rectangle. Similarly, the user selects via the FgControlPanel both the color and transparency factor of a small rectangle painted over the larger one. The rectangles are displayed on the OutputPanel. The resulting pixel value in the overlay area is displayed on the output
Demo 4: Pixel Handling CreateImageApplet
ImagePanel
Create an image from a pixel array using an instance of MemoryImageSource.
Demo 5: Pixel Handling AnimationApplet Use MemoryImageSource to create an animated image.
12 Demo 1:
Printing Java Interface Components
PrintTestApp This application illustrates printing a user interface. In this case the user interface is a frame that displays an image.
References: Apollo16Lander.jpg, dcx-flight.jpg
Demo 2: Cursors: CursorTestApplet Demonstrate the different cursor styles according to which button the cursor lies over.
Demo 3: Mouse Buttons MouseButtonsApplet Demonstrate how to detect which mouse button was pressed. When the cursor is over the top panel, any mouse button press will generate a text description in the botton panel.
Demo 4: Popup Menus PopupApplet
PopupPanel
Demonstration of popup menus. Select a color of a panel fromt the menu.
Demo 5:
Handling Keystrokes
KeyTestApplet
KeyTestPanel
Demonstration of listening for key strokes.
Demo 6: Audio

AudioTestApplet
AudioPanel

Demonstrate playing an audio clip. Click on a button and it plays a clip.
Resouces: boing.au
Demo 7:
Timing & Performance
TimeTest

Run timing tests on four types of code:

  1. Vector element access
  2. ArrayList element access
  3. ArrayList element access.
  4. Object array access (using Integer objects
Demo 8:
The Graphics Toolkit
FrameCenterApplet
ParticleCenterFrame
Same as FrameApplet in Chapter 20 except that it centers the frame in the monitor display area.
Demo 9:
AppletContext & Building a Custom AppletViewer
StartJAppletViewer Illustrates how a JFrame subclass can implement the AppletStub & AppletContext interfaces to build a rudimentary appletviewer. The getDocumentBase (), getImage (URL url), and getCodeBase () methods were implemented in detail.

 

  Part 1: Java Supplements
Ch Course Page Class Code Description
6 AWT Demo 1: Basic Graphics
SimpleDrawApplet Example demonstrating drawPolyline() in AWT.
AWT Demo 2:
Simple Drawing Techniques
SimpleDraw1Applet
Demonstrate some basic drawing methods on an AWT applet panel.
AWT Demo 3:
Drawing Text
TextApplet Draw text on an applet panel in AWT.
AWT Demo 4:
UI Components
CompsApplet Three components laid out on a AWT applet.
AWT Demo 1:
Java2D Shapes & Areas
ShapesApplet
ShapesPanel
Demonstration of stroke and painting in Java2D.
Java2D Demo 2:
Shapes & Areas

AreasApplet
AreasPanel

This applet illustrates drawing 2 Shape objects, then converting them to Area objects combined by Addition, Intersection, Subtraction & XOR
Java2D Demo 3: Paint & Stroke StrokePaintApplet
StrokePaintPanel

Ellipse2D drawn with:

  • 10 pixel wide stroke and black paint
  • red dashed, 8 pixel wide stroke and red paint
  • draw with 10 pixel stroke and blue paint, then fill with red.
  • same but use anti-aliasing rendering hints.
Java2D Demo 4: Transforms TransformApplet
TransformPanel
Demonstration of AffineTransform. Create and draw a rectangle and then apply a series of transforms to see the effects.
Java2D Demo 5: Gradients & Textures GradientsApplet
GradientsPanel
Demonstration of gradient paint by drawing three shapes and filling them with a gradient of red to blue.
Java2D Demo 6: Gradients & Textures TextureApplet
TexturePanel
Demonstrate texture paint by using an image to fill three different shapes.
Java2D Demo 7: Text IteratorTextApplet
IteratorTextPanel
Demonstration of a text interator. Use an AttributeString object to set each character to its own font and color.
Java2D Demo 8: Text TexturedTextApplet
TexturedTextPanel
Demonstrate using texture paint when drawing text.
7 AWT Demo :
A Button with AWT
ButtonApplet This AWT applet demonstrates the Button and Label components with events handled with ActionListener implementation.
AWT Demo 2:
The Canvas Component
CanvasApplet Demonstrates the use of the Canvas component for drawing.
AWT Demo 3:
A GUI with AWT Components
GUIApplet
TheFrame
An Applet instance creates a fame with a menubar and dropdown menus, all in AWT mode.
Swing Demo 1:
Dialogs with JOptionPane
DialogsApplet Generates various types of dialogs with JOptionPane selected from options in a JComboBox.
Swing Demo 2: JDialog MakeJDialogApplet
MakeJDialogJFrame
GetUrlDialog
TextSetable

Illustrates the creation of a JDialog subclass. It follows the example of a request to the user to input a URL address.

The applet uses a JFrame subclass with a menubar and buttons that can create an instance of GetUrlDialog, which is a subclass of JDialog. It will pass the URL text back to the frame using a method from the TextSetable interface.

UI Enhancement Part 1: Demo 1 GridBagAppletV1
GridBagPanelV1
Demonstrate the use of Insets to set the dimensions of the border area around a component.
UI Enhancement Part 1: Demo 2 GridBagAppletV2
GridBagPanelV2
Demonstrate the use of the Border class and its factory methods to create borders around a componet.
Resources: bluebox.jpg, redDot.gif
UI Enhancement Part 1: Demo 3 GridBagAppletV3
GridBagPanelV3

Demonstrate the use of Icons for display on buttons and labels.
Resources: bluebox.jpg, picButton.jpg, picButtonPressed.jpg, face.gif, redBall.gif, redDot.gif

UI Enhancement Part 2: Demo 1 GridBagAppletV4
GridBagPanelV4

Demonstrate the how to find a list of the currently available Look & Feel objects and to reset the UI to a new one.
Resources: bluebox.jpg, picButton.jpg, picButtonPressed.jpg, face.gif, redBall.gif, redDot.gif

8 Java2D Demo 1:
Animation with Java2D
Drop2DApplet
Drop2DPanel
Similar to the the dropped ball applet in Chapter 8: Java, this version uses antialiasing to draw ball with a smooth edge.
Demo 1: Cloning Example
ExampleDeep
Application that illustrates cloning instances of a class. Do both a shallow and a deep clone.
Demo 2: Cloning CloningJApplet8 Same but with a JApplet interface, including button controls.
9 Demo 1: Text Character I/O SingleCharIOApp Demonstrate reading characters from the console using the standard input from System.in wrapped with InputStreamReader.
Demo 2: Text Character I/O SingleCharPWApp Demonstrate reading characters from the console using the standard input/output from System.in/System.out wrapped with InputStreamReader & OutputStreamWriter, resp. Here wrap PrintWriter around the OutputstreamWriter.
Demo 3:
Random Access in a File
RandomFileTest Use RandomAccessFile to write a number into a file. Command line specifies the single integer value to write, the position in the file where it is to be written, and the name of the file, which should contain a series of integer values. The position will be in terms of integer values, not bytes. The file will be created if it doesn't exist already.
Demo 4:
ZIP/GZIP Compression and Decompression: Demo
ZipGzipApp
ZipGzipper
Outputable

This program creates a GUI in which the user selects a file for compression or decompression. The user can also choose an output directory for where compressed or decompressed files will be sent.

Uses the static methods from the ZipGzipper utility class described on this page for the compression and decompression tasks. The class implements the Outputable interface to provide for print methods that send messages to the text area to show the history of the user's actions.

Demo 5:
PipedStreams
PipedAnalyzer
Analyze1Thread
Analyze2Thread

Demonstrate piped streams I/O between threads. Data from a file is read and "analyzed" by the first thread and then its output is passed via a piped stream to the second thread which does further analysis on the data. It then passes its data via a pipe to a method for output to the console.
Demo 6: More NIO: Using
ByteBuffer to Convert Bytes
to/from Primitive Types
HistNIOApp
HistNIOTools

HistNIOApp is the same as HistIOApp discussed in Chapter 9: Tech.

It uses HistNIOTools, which contains several static methods used to write and read histograms to disk files. This utility class is identical to HistIOTools in Chapter 9: Tech except for the following four methods, which use NIO techniques:
readFile(), writeFile(), packHistogram(), unpackHistogram()

10      
11 Demo 1:
Pixel Handling with the BufferedImage
CreateBufferedGrayImageApplet Display a gray scale image with a BufferedImage and dispaly it on the DrawingPanel that is added to the applet.
Demo 2:
Pixel Handling with the BufferedImage
AnimationWriteableRasterApplet Demonstrate animation of a BufferedImage object by direct modification of its pixel data.
Demo 3: Convolution Filtering EdgeDetectApplet Input image on left, filtered image on right. Demonstrate convolution filtering with an edge filter.
Resources: liftoff.jpg, saturn.jpg, saturnVoyager.jpg
Demo 4:
Affine Transforme Filter:
TransformApplet Input impage on left, filtered image on right. Demonstrate an affine transform of an image. Sliders determine the degree of shearing.
Resources: saturnVoyager.jpg
Demo 5: Lookup Tables LookupTableApplet Input image on left, filtered image on right. Use a lookup table to provide a threshold filter on all color components. A slider lets the user select the threshold.
Resources: saturn.jpg, saturnVoyager.jpg
Demo 6: Lookup Tables LookupTableOneColorApplet Input image on left, filtered image on right. Use a ookup table to provide a threshold filter on a single color component. A slider lets the user select the threshold.
Resources: saturn.jpg, saturnVoyager.jpg
Demo 7:
Rescaling and ColorConvert Filters
RescaleApplet Input image on left, filtered image on right. Demonstrate the rescale filter. One slider chooses the scale factor and the other the offset.
Resources: saturnVoyager.jpg
Demo 8:
Rescaling and ColorConvert Filters
ColorConvertApplet Input image on left, filtered image on right. Use color conversion to change a color image to gray scale.
Resources: saturnVoyager.jpg
Demo 9: Custom Filters RotateColorsApplet
RotateImagePanel
RotateOp
Demonstration of the RotateOp filter. Most of the work is done on the RotateImagePanel, which is displayed on this applet. The applet is Runnable and periodically signals to the RotateImagePanel to repaintitself with the image filtered for a different color.
Resources: liftoff.jpg
AWT: Demo 1:
Reducing Flicker 1 :
Override Update
FlickerMax_Applet7 Mouse drags a image over a checkerboard background. Lots of flickering as the image moves.
Resources: Apollo16Lander.jpg
AWT: Demo 2:
Reducing Flicker 1 :
Override Update
Update_Applet7 Same as Demo 1 but override the update() method.
Resources: Apollo16Lander.jpg
AWT: Demo 3:
Reducing Flicker 2 :
Clipping
Clipping_Applet7 Same as Demo 2 but clip the area around the image.
Resources: Apollo16Lander.jpg
AWT: Demo 4:
Reducing Flicker 3 :
Double Buffer
DoubleBuffer_Applet7 Same as Demo 2 but with double buffering of the display area on the panel.
Resources: Apollo16Lander.jpg
12 Demo 1: Java & the Web Browser BrowserTestApplet A utility to find the browser or plug-in name via the string returned from the System.getSecurityManager () method.

 

  Part 1: Tech
Ch Course Page Code(s) Description
2 Demo1: Floating Point Special Values FPSpecialValues Applet that demonstrates various special FP cases such as NaN, infinity, etc.
Demo 2: MathTest1 MathTest1 Applet that demonstrates various mixing and casting cases.
3 Demo: Histogram Class

BasicHist,
BasicHistApplet1,
BasicHistApp1

A class with the bare essentials needed for histogramming of data. Used in an applet and app demos to show distribution of output from a Gaussian random number generator.
Complex Number Class BasicComplex Class to represent a complex value. Includes only add and subtract methods.
4 More Complex Class Complex Expanded complex number class with static methods for adding and subtracting two Complex instances.
Improved Histogram Class BetterHist
Illustration of class inheritance. Uses super() in the constructor. Adds statistics calculations.
5 Demo 1 : DecimalFormat Class DecimalFormatDemo
This demo illustrates several format patterns that one can use with the DecimalFormat class.
Demo 2 : DecimalFormat Class FPFormatDF An interactive program that allows you to set the number of fractional places for both decimal and scientific formats for a quotient value from factors that you enter.
Demo 3: System.out.printf() PrintDemo Use the System.out.printf() method, added by J2SE5.0, to Send formatted numerical output to the console.
Demo 4: Format Class - Core Java CJ_Applet Use the open source freeware class originally developed for the Core Java book, for formating numerical strings.
Demo 5: Format Class - Core Java FPFormatCJ Similar interactive program as FPFormatDF but uses the Core Java Format classs.
6 Demo 1 :
Starting a Plotting Package
PlotDemoApplet,
DemoPanel, PlotPanel, PlotFormat
Create the abstract class PlotPanel that will be used for creating a plot frame, title, axes scaling, etc. It's subclasses witll plot the data inside the frame. This demo plots some dummy points with different symbols and error bars. PlotFormat uses DecimalFormat in a static method to format numbers for the axes scaling.
Demo 2: Drawing Panel - Polymorphism in action PlotDrawApplet, DrawPanel DrawFunction, DrawLine, DrawPoints, PlotPanel, PlotFormat
Demonstrate another example of a subclass of PlotPanel. Here the DrawPanel uses two subclasses of DrawFunction to draw data points with error bars and a line through it.
Demo 3 :
Histogram Plot
DrawHistApplet,
HistPanel, PlotPanel, PlotFormat,Histogram
Use a subclass of PlotPanel to display the contents of an instance of the Histogram class.
7 Demo 1 :
Histogram Display with User Interface
UIDrawHistApplet
Histogram, HistPanel PlotPanel, PlotFormat
Add buttons and a textfield to let the user re-run the histogramming of a Gaussian random number generator output. Build on the PlotPanel class from the earlier examples.
Demo 2:
Generating Non-Uniform Distributions
RanDistTransformApplet
Histogram, HistPanel PlotPanel, PlotFormat
Generate a distribution in a histogram that follows a radioactive decay distribution using the transform method.
Demo 3:
Generating Non-Uniform Distributions
RanDistGaussianApplet
Histogram, HistPanel PlotPanel, PlotFormat
Generate a Gaussian distribution of numbers using a uniform random number generator and the polar transform method.
Demo 4:
Histogram Statistics
HistStatsApplet
HistogramStat
Histogram, HistPanel PlotPanel, PlotFormat

Display an instance of the HistogramStat. Clicking on the Stats button creates a frame that displays the stats for the Gaussian distribution of random values.

HistogramStat is a subclass of Histogram that adds various statistical information about the contents such as the mean, standard deviation, etc.

8 Dem 1: Timers TimerHistFillApplet
MakeData, Updateable
Histogram, HistPanel PlotPanel, PlotFormat

Similar to UIDrawHistApplet in Chapter 7: Tech except that here a timer (java.util.Timer and its helper java.util.TimerTask) is used to allow for display of the histogram during its filling. A separate thread object, MakeData, creates the data. The class implements the Updateable interface to provide for callbacks.
Dem 2:
Histogram with Adapting Range
AdaptHistFillApplet
HistogramAdapt
HistogramStat

Histogram, HistPanel
MakeData, Updateable PlotPanel, PlotFormat

Similar to TimerHistApplet in the above Demo 1: Timers except that it uses HistogramAdapt. It also borrows code from HistStatsApplet in Chapter 7: Tech for displaying statistical info in a popup frame. As before, a timer is used to indicate when an update to the plot should occur. The data making is done in the thread object, MakeData, and the class implements Updateable interface to provide for callbacks.

HistogramAdapt is a subclass of HistogramStat, which is in turn a subclass of Histogram. Provides for dynamically extending the histogram limits to fit all input data values.

Dem 3: Sorting SortHistFillApplet
BubbleSorter, Sorter
HistogramAdapt
HistogramStat

Histogram, HistPanel
MakeData, Updateable PlotPanel, PlotFormat

This applet/app class operates the GUI sorting interface. Similar to the above AdaptHistFillApplet class except for adding a "Sort" button and extra code in the update() and done() methods to handle call backs from the sorter.

BubbleSorter is a subclass of Sorter that carries out the simple bubble sort method. It provides a sort method for both integer and double arrays. It also provides the run() method for threading. After each step it calls back to the owner via the Updateable interface method update(). It also calls the done() method after it finishes the sort.

Sorter is an abstract base class for sorter algorithm classes. Extends Thread so that the sorting can be done as a separate process.

Dem 4:
Histogram Median
MedianHistFillApplet
HistogramMedian

HistogramAdapt
HistogramStat

Similar to AdaptHistFillApplet in in Demo 2 but except that here the median value is added to the statistics popup frame and an instance of HistogramMedian, a subclass of HistogramAdapt is used.

HistogramMedian is a subclass of HistogramAdapt that overrides the getStats() method so that it can calculate the median and add it to the statistics array returned from the method.

Dem 5:
Refactoring Class Designs
HistR1Applet
HistogramAdaptR1
HistogramStatR1
Histogram, HistPanel
MakeData, Updateable PlotPanel, PlotFormat

Displays an instance of HistogramAdaptR1 on a HistPanel. Generates data the same as in AdaptHistFillApplet in Demo2.

HistogramAdaptR1 is a subclass of HistogramStatR1 that provides histograms that offer the option to adapt the range to keep all points within the bin limits plus statistical information on the distribution. The class uses a data array to hold each individual entry. This class derives from a combination of HistogramAdapt and HistogramMedian.

HistogramStatR1 is derived from a refactoring of Histogram, HistogramStats, HistogramAdapt, and HistogramMedian. It provides all of the methods and properties of those classes.

Dem 6:
Histogram with Error Bars
HistErrorApplet
HistErrPanel

HistogramStatR1

Histogram, HistPanel
MakeData, Updateable PlotPanel, PlotFormat
DrawFunction

Uses the HistErrPanel to display contents of an instance of HistogramStatR1. It follows the same basic form as the Timers demo where instances of java.util.Timer and java.util.TimerTask update the display of the histogram during the filling of the histogram. Includes a "Go" button to initiate the filling of the histogram. To simulate data taking, a combination of a Gaussian and random background values are generated. The number of values come from an entry in a text field.

HistErrPanel displays the histogram data with the option of points and error bars in addition to the usual bin column type display. It is a subclass of PlotPanel.

9 Demo 1:
Input/Output for the Histogram Class: Application Demo
HistIOApp
HistIOTools

HstFilter
Histogram, HistPanel
PlotPanel, PlotFormat

This application creates a histogram and fills it with a Guassian generated random values. The menu bar offers the options to Save the histogram to a file or to open a file to read a histogram from. It uses the static methods in HistIOTools class to do most of these tasks.

HistIOTools contains several static methods used to write and read histograms to disk files.

Demo 2: I/O for the Histogram Class: Object Serialization HistIOSerialApp
HistIOSerialTools
HstFilter
Histogram (Serializable)
Histogram, HistPanel
PlotPanel, PlotFormat

This application follows closely to the previous HistIOApp example except that it uses the object serialization methods in HistIOTools class to save and read back histogram files.

HistIOSerialTools contains the two static methods:

writeSerialFile(File file, Histogram histogram) method writes a Histogram object to a file with an OutputObjectStream.

readSerialFile(File file) reads a histogram from such a file using theInputObjectStream.

For this demo we created a special version of Histogram that is identical to the Chapter 6: Tech Histogram except that it implements the Serializable interface.

Demo 3: Histogram Stream Classes: Demo 2 HistStreamApplet
StreamedHistPanel
MakeSensorData
Histogram, HistPanel
PlotPanel, PlotFormat

This applet/application uses StreamedHistPanel objects to display the contents of 3 Histograms that simulate distributions of sensor data. The basic form of the class goes as TimerHistFillApplet in Chapter 8: Tech. However, data is sent to the StreamedHistPanels as OutputStreams.

Data is generated from an instance of MakeSensorData in a thread to simulate the input of data events at random times. The three sensors each produce a Gaussian distribution of values but they are transformed by different slopes and offsets (or pedestals) to represent variations in the sensor hardware.

StreamedHistPanel extends HistPanel. It provides a HistPanel destination for an output stream. It uses an instance of HistPanel to display the data and to hold the data values in an array.

It uses an innter class called HistogramOutputStream that extends OutputStream. An instance of this stream object is provided with the getOutputStream() method. Data written to theo HistogramOutputStream is added to the histogram that is displayed on the panel.

MakeSensorData is a Runnable class that generates a Guassian distributed random data and write it to the HistogramOutputStream for display on the histogram.

Demo 4:
Filtering Data in a Stream to a Histogram
HistFilterStreamApplet
HistFilterOutputStream
StreamedHistPanel
MakeSensorData

Histogram, HistPanel
PlotPanel, PlotFormat

This applet/application resembles HistStreamApplet above but adds 3 extra StreamedHistPanels whose input streams are each wrapped by a HistFilterOutputStream. These panels display data for the same 3 sensors but calibrated by the HistFilterOutputStream.

HistFilterOutputStream wraps an OutputStream and overrides the write(int datum) method. The write method makes a slope and pedestal correction to the data value and then writes it to the OutputStream.

10      
     
11 Demo 1: Fractal Generation - Drawing FractalsApplet
FractalController
FractalPanel
MousePlotPanel
MouseHandler
DrawBifurcation
DrawJuliaSet
DrawJuliaSetNewton
DrawMandlebrot
DrawFunction,

Complex

PlotPanel, PlotFormat

Display a fractal algorithm selected from a list. The X,Y text fields display the dimensions of the area in which the fractal generation occurs. The user can drag the cursor to create a rectangle whose position and dimensions are used to generate a new fractal pattern. The new dimensions are displayed in the X,Y text fields.

The DrawFunction subclasses, i.e. DrawBifurcation, etc, carry out the fractal algorithms and draw the patterns.

 

Demo 2:
Fractal Generation with Images

FractalsImgApplet
DrawBifurcationImg
DrawJuliaSetImg
DrawJuliaSetNewtonImg
DrawMandlebrotImg
FractalController
FractalPanel
MousePlotPanel
MouseHandler
Complex

DrawFunction,

PlotPanel, PlotFormat

Similar to FractalsApplet except that it selects the fractal patterns are first generated as off-screen images that are then drawn in one step. The DrawBifurcationImg, DrawJuliaSetImg, etc. classes do the image creation.
     
     
12      
     

 

  Part 1: Physics
Ch Name Code   Description
2 Demo 1: Falling Object

FallingObject_Applet1
FallingObject_App1

Uses the Euler method to location and speed of an object falling in constant gravitational field. Separate applet and application versions.
Demo 2: Harmonic Motion - Predictor-Corrector Spring_Applet1
Spring_App1
use the PC method to solve for spring motion.
3 Particle Class Particle Class to illustrate objects in physics.
Not used in a demo program.
Demo 1: Root finding with Bisection Bisection_Applet5 Use the bisection root finding method to solve for the landing point of a projectile.
Demo 2: Root Finding with Newton's Method Newton_Applet5 Use Newton's method to find the landing point of a projectile.
4 Demo 1: Projectile Motion with 2nd Order R-K

RK2ndApplet.java,
RungeKutta2nd.java, Derivable.java ,

Use the second order Runge-Kutta method to calculate the trajectory of a ballistic projectile.
Demo 2: Runge-Kutta Method RK4thApplet.java, RungeKutta4th.java Use fourth order Runge-Kutta method to calculate the trajectory of a ballistic projectile.
Demo 3: Shooting at a Target ShootApplet.java , Shooter.java, RungeKutta4th.java Illustrate the shooting method for solving a 2-D differential equation problem. Uses 4th order R-K from previous demo. Discrete Newton technique used to find the parameters for the shooting.
5 Demo 1: Integration Methods IntegrateApplet.java, TrapezoidInteg.java, RectInteg.java ,
Integrator.java
Function.java
Demonstate the rectangular and trapezoidal approaches to numerical integration. We also demonstrate more sophisticated object oriented program design based on interface implementations.
Demo 2: Simpson's Integration Rule

SimpsonApplet.java,
SimpsonInteg.java

Uses the Integrate interface discussed in Chapter 5: Physics : Demo 1 to create class to carry out the Simpson's rule integration.
6 Demo 1: Display Text Data in a Swing Panel FallingObjectApplet.java,
TextOutputPanel.java,
Outputable.java
Demonstrate a graphical user interface by using the Chapter 2: Physics : Demo 1: Falling Object code to send text output to a Swing panel rather than to the console.
Demo 2: Plot Data with Java Graphics

DataPlotApplet.java,
DataPanel.java,
PlotPanel, PlotFormat,

This program draws data points on the PlotPanel component discussed in Chapter 6: Tech : Starting to Plot. Here we create the DataPanel subclass of PlotPanel. As in the Chapter 6: Physics: Demo 1, we use code from the Euler method demo program in Chapter 2: Physics : Falling Object.
7 Demo 1 :
Generating Custom Random Distributions
RanDistAnglesApplet
Histogram, HistPanel PlotPanel, PlotFormat
Creates a random distribution of angles as might be seen for tracks entering a detector element in a particle scattering experiment.
Demo 2:
Histogram Distribution
RanDistHistApplet
Histogram, HistPanel PlotPanel, PlotFormat
Generate a distribution in a histogram that follows a radioactive decay distribution using the transform method discussed above.
Demo 3:
Monte Carlo Integration
MCPlotApplet
MCPanel
SinFunc, Function
PlotPanel, PlotFormat

Integrates 1-D functions using a Monte Carlo approach. The user generates different functions via the buttons.

MCPanel is a subclass of PlotPanel that draws a function and the scatter of points used for the MC integration. The function plot is created with a Polygon object. By wrapping the points around the boundary we can use the contains() function in Polygon to obtain the number of points below the function curve.

SinFunc is a function used to generated the curve for integration. Implements the Function interface.

8 Dem 1:
Least Squares Fit to a Straight Line
LsfLineApplet
FitLine, Fit

DrawFunction, DrawLine DrawPoints
, DrawPanel
Histogram, HistPanel
PlotPanel, PlotFormat

Generates points along a line and then fits a straight line to them. This simulates track fitting in a detector. The number of tracks and the std. dev. of the smearing of the track measurement errors taken from entries in two text fields. Two histograms record differences in the slope and intercept for the fitted track with the generated track. A third histogram holds the residuals.

FitLine, a subclass of Fit, does a least squares fit to a straight line. Fit is an abstract class that allows for subclasses to apply different kinds of data fitting algorithms to 2-D data.

Dem 2:
Least Squares Fit to a Polynomial

PolyFitApplet
FitPoly, DrawPoly
Fit

DrawFunction, DrawPoints

DrawPanel
Histogram, HistPanel
PlotPanel, PlotFormat
+ classes from the
JAMA: Java Matrix Package


This program generates points along a quadratic line and then fits a polynominal to them. A histogram displays the residuals.

See Demo 2 page for descriptions of other classes.

Dem 3:
Fitting Histogram With Errors
HistFitApplet
HistogramFit
HistogramStatR1
FitPoly, DrawPoly
Fit
DrawFunction, DrawPoints
DrawPanel, DrawLine
HistErrPanel
Histogram, HistPanel
PlotPanel, PlotFormat

Create a random distribution of values and then fit a polynominal to the bin values.

HistogramFit provides a static class that takes a histogram as an argument and fits the distribution of values to a polynominal of a given degree.

Dem 4: Discretization    
Dem 5:
Timing in Simulations
   
9 Demo 1:
Physics Simulation Program
DropTestApplet
DropPanel
DropModel
Histogram, HistPanel
PlotPanel, PlotFormat

Simulate the droppinig of a mass in a constant gravitational field. This class provides the top level applet/app that controls the program and displays on the applet panel the user interface.

DropPanel is a subclass of PlotPanel that displays the experiment simulation, i.e. the falling mass

DropModel generates the physics data for the simulation.

Demo 2:
Experiment Simulation with a Detector
DropTestDetectApplet
DropPanelDetect

DropModelDetect

DropDetector1

Detector

Histogram, HistPanel
PlotPanel, PlotFormat

Simulate an experiment that measures the acceleration of a dropped mass. The detector looks at the times when the mass crosses fixed positions and calculates the change in velocity between the top pair and the bottom pair of measurements.

See Demo 2 page for descriptions of other classes.

Demo 3:
Experiment Simulation with Analysis Module
DropTestAnalysisApplet
DropAnalyzer
DropDetector2
DropPanelDetect

DropModelDetect

Detector

FitPoly, DrawPoly,
Fit

DrawFunction, DrawPoints

DrawPanel,

PlotPanel, PlotFormat

Simulate a experiment in which a dropped ball leaves marks every DT interval, as in a spark chart experiment. Includes fitting of the data with LSQ fit using previous classes developed for that purpose.

See Demo 3 page for descriptions of other classes.

10 Demo 1:
Drop Simulation data generator
DropGenerator
DropDetector2
Detector

DropPanelDetect

DropModelDetect

PlotPanel, PlotFormat
Simulate the mass drop experiment and generate a file with the data for each event. Similar to Demo 3 of Chapter 10 except that the analysis part has been split off into Demo 2 below. Also, the GUI provides a check box for the user to select for data output and a text field for the user to enter the name of the data file.
  Demo 2:
Drop Data Analysis Program
DropDataAnalysis
DropAnalyzer

FitPoly, Fit
,
DrawPoly

DrawFunction, DrawPoints

DrawPanel,

PlotPanel, PlotFormat
+ classes from the
JAMA: Java Matrix Package
This application program with a frame reads in and analyzes the data generated by the DropGenerator simulation program. Uses DropAnalyzer from Chapter 9. The user selects the data file by opening a JFileChooser via a menu item in a dropdown munu from a menu bar.
11 Demo 1:
Drop Simulation with Instrument and Systematic Error
DropGenCalSysErr
DropDetector3
DropDetector2
Detector

DropPanelDetect

DropModelDetect

PlotPanel, PlotFormat
Generate more realistic data for the mass drop experiment demo by allow the user to add an offset to the position data to simulated instrument effect. A special calibration run mode allows for determination of the instrument effect. The user can also include a systematic error on the time span between measurements.
  Demo 2:
Drop Data Analysis with Calibration
DropDataAnalysisCalSysErr
DropAnalyzerCalSysErr

FitPoly, Fit
,
DrawPoly

DrawFunction, DrawPoints

DrawPanel,

PlotPanel, PlotFormat
+ classes from the
JAMA: Java Matrix Package
Analysis of the output of DropGenCalSysErr allows for a "calibration" constant to be subtracted from the position data.
12 Demo 1:
Plotting, Histograming, and Fitting with JAIDA

PolyFitJAIDAApp
+ JAIDA packages

Remake the Chapter 8: Physics : Demo 1: Least Squares Fit to a Straight Line with the JAIDA plot, histogram and function fitting classes.
       

 

Part 2: Networking
Ch Course Page
Class Source Code Description
13 Demo 1: URL Class  ParseAddress Parse a URL address into its components.
Demo 2:
Reading a File from a URL
ReadFileViaURL Demonstration of reading a local file via a URL.
Resources: data.txt
Demo 3: InetAddress LocalAddress Show how InetAddress can provide the local IP address.
Demo 4: InetAddress TranslateAddress Translate an IP argument to a host name or * a host name to an IP address.
Demo 5: Sockets
WhoisApplet This program displays the whois output in a text area
14 Demo 1: Running HTTP Server

MicroServer
Worker

MicroServer is an application to create a ServerSocket object and spin off a threaded process to serve each client.

Workder is a threaded process that serves the client connected to the socket.

Demo 2:
Security Manager & Policy Files
MicroServerSecure
Worker
MicroServerSecure is identical to MicroServer above.
Worker is modified to output error messages for attempts to access files outside the permitted directories.
Demo 3: Clent Application

ClientApp

Application that accesses the above servers. It provides a GUI for specifying the IP address and the file to request.
15 Demo 1:
Run the Data Server Program
DataServer
DataWorker

Creates a user interface that consists of a frame with a text area to display messages, a text field to set the servers port, and a start button. The drop down File menu holds an Exit item to stop the program. It uses a ServerSocket to make socket connections with the clients. When a connection is made ithands off the socket to an instance of DataWorker to provide data to the client

An instance of DataWorker tends to a client connected to a socket obtained from the ServerSocket object. It begins with a simple login procedure for the client. It then enters a loop to respond to requests for data from the client. This version of DataWorker just creates dummy data to send to the client. The client periodically sends a request for more data and the DataWorker sends a set of 6 integer values, each generated according to Gaussian random number generator of a different std. dev. and offset.

Demo 2 :
Run the DataClient Program
DataClient
DataClientWorker UHistogramStatR1
HistogramAdaptR1
Histogram, HistPanel,
PlotPanel, PlotFormat

Create an interface for the user to initiate a connection with the server at the given host address. It communicates via a socket at port 2222. The user name is required for the login. A text area displays messages generated for different steps in the setup and communications with the server.

DataClientWorker is a Thread subclass that communicates with the server and periodically requests a set of data. When it receives the data it passes it to the DataClientApplet parent, which then displays the data in the histograms.

Demo 3 :
Server for the Experiment Simulation

SimServer
SimWorker
SimApplet
SimController
NetStreamMethods
SimUtil
DropDetector2
DropPanelDetect

DropModelDetect

Detector

This application monitors a ServerSocket for requests for connections from clients. The port can be selected in the text field (default 2222). The text area shows messages indicating the status of the connection with the client(s). When a connection socket is created, it is handed over to a SimWorker object that is dedicated to serving that client. Maintains a list of clients and limits the total to a set number.

See Demo 3 page for descriptions of other classes.

Demo 4: Demonstration Client Applet for the Experiment Simulation SimClient
SimClientWorker
NetStreamMethods
SimUtil
DropAnalyzer
FitPoly, DrawPoly,
Fit

DrawFunction, DrawPoints

DrawPanel,

PlotPanel, PlotFormat

Derived from the demonstration program Ch.9: Physics: DropTest Analysis_JApplet11. The mass drop classes here become part of the server simulation. The fields at the top allow the user to enter the number of drops the simulator should execute and what smearing (std. dev.) should be made on the data points. When a connection is made to the sever, a SimClientWorker object is created to take care of all communications with the server.

See Demo 3 page for descriptions of other classes.

18

RMI Server Demo Code Listing

RMI Client Demo Code Listing

RMI Demo Support Files Listing

Server:
RMIExampleServer
RMIExampleImpl
RMIExampleInterface
Client:
RMIExampleClient - local path
RMIExampleClient - remote path
Support files:
README.txt
client.policy
local-server.policy
build.bat
clean.bat
client.bat
server.bat

Client/Server demo with RMI. See the book for details.

Note that these classes belong to specific packages so must be placed in the proper directories.

The bat command files apply to MSWindows platforms.

19

CORBA Server Demo Code Listing

CORBA Client Demo Code Listing

CORBA Demo Support Files Listing

Server:
Cor19Server
Cor19Servant
Client: Client
IDL: server.idl
Support files:
README.txt
build.bat
clean.bat
client.bat
server.bat

Client/Server demo with CORBA. See the book for details.

Note that these classes belong to specific packages so must be placed in the proper directories.

The bat command files apply to MSWindows platforms.

20 RMI Client/Sever with Simulation

Simulation:
Simulation
SimulationThread
SimData
Server:
Server
ServerInterface
FactoryInterface
Client: Client
Support files:
README.txt
java.policy
build.bat
clean.bat
client.bat
server.bat
hist.jar

Client/Server demo with RMI that runs a simulation and sends results to the client. See the book for details.

Note that these classes belong to specific packages so must be placed in the proper directories.

The bat command files apply to MSWindows platforms.

hist.jar contains the class files for Histogram, HistPanel, PlotPanel, and PlotFormat from Chapter 6: Tech: Histogram Demo. See above.

 

Part 3: Out of the Sandbox
Ch Course Page
Class Source Code Description
22 Basic JNI Demo

Java code:
JNIDemo.java
JNIHelloWorld.java
StringExample.java
ArrayExample.java
C++ code:
NativeJNIDemo.cpp
NativeHelloWorld.cpp
NativeArray.cpp
Support files:
build.bat
clean.bat
run.demo.bat
run.hello.bat
run.string.bat
run.array.bat
README.txt

Java Native Interface example connecting a Java code to C++.

Note that these classes belong to specific packages so must be placed in the proper directories.

The bat command files apply to MSWindows platforms.

23 Demo 1: System Properties

SysProperties

List the system properties available to applets and to applications.
Demo 2:
Running External Programs
RunTimeApp Demonstrate how to run an external program, which here is just the directory command.
Demo 3:Port Operations PortList List all the ports available on the local machine.
Demo 4: Port Operations PortTest Look for COM# ports on the local machine.
Demo 5: Port Operations PortListOpen Check each port to see if it is open.
Demo 6:
Serial Port I/O Demo

SerialToJavelin
Outputable,

This class provides a user interface for communications with a device connected via the serial port. In this case, the device is the Javelin evaluation card discussed in Chapter 24. The class is intended to demonstrate the classes, methods, and fields in the javax.comm package needed to access and do I/O over a serial port.
24 Demo 1:
Java Javelin Processor Demo
SendTempDataFromJavelin
TempDataGenJavelin
DataGenerator
This program transmits temperature readings from the DS1620 chip when it receives a request over the serial line. The request must include a password number at the start. If the password is OK, then a temperature value is obtained and transmitted.
Demo 2: GPS with Javelin For use in a UAV, the Javelin is tested on the benchtop to do measurements with a GPS device and a radiation counter/ Student project by Hosseyn Karimi Garari, Daryoush Mansouri, Radiation Surveillance by Unmanned Aerial Vehicle (UAV), Diploma Work, Physics Dept., Royal Institute of Technology, 2003. (MS Word file - in Swedish)
Demos 3: Solar/Temperature Statio with Javelin Solar/Temperature measurements system with Javelin processor. Student project by Jaakko Pajunen: A Task in Java Embedded Circuit Programming with Javelin Stamp, by Jaakko Pajunen, March 14, 2004 (pdf) - project report.
Demo 4:
SNAP Processor Demo: Web Server
SnapAdcServer
Worker
Version of Chapter 14 MicroServer program modified to work on the Imsys SNAP system. The Worker is a threaded process to serve the client connected to the socket. It reads an ADC that is connect to a voltage source, e.g. a solar panel output.

Starter Programs

Applets & Applets with main()
Starter
Description
StartApplet1 init() only.
StartApplet2
init()  and one support class called Test.
StartApplet3 init() , one support class called Test, which is extended by Test1, and then Test2 extends Test1.
StartApplet4 init()  and and an interface called Testable, which is implemented by two support classes - Test1 & Test2.
StartApplet5 init() and also an empty method, plus a main() for using the program as an application.
StartApplet6 Implements an interface - called Testable. Change the name of the interface to a name relevant to your program. Also, you may want to save the interface definition to its own file, e.g. Testable.java
StartApplet7 Code to allow an applet that can also run as an application; that is, it includes the main() method.
StartApplet8 Applet with two extra classes - Test1 & Test2 that implement an interface - Testable. Same as starter Start_Applet4 except it includes the option of running as an application.
StartApplet9 Use this starter to create an applet that implements the Runnable interface. It overrides the run() method and holds a Thread reference used in the run() method to stop a loop.
StartApplet10 Use this starter, which implements ActionListener, to create an applet with a button or other component that generates an ActionEvent.
StartApplet11 Use this starter to create an applet that opens a frame. The frame create a menubar with a drop down menu. Closing the frame is also providing as is standalone operation.
With Swing Components
StartJApplet1 JApplet subclass that holds an instance of a JPanel subclass called GenericPanel.
StartJApplet2 JApplet subclass that holds an instance of a JPanel subclass called DrawingPanel with paintComponent(Graphics g).
StartJApplet3 Implements ActionListener and holds a JButton instance.
StartJApplet4 Holds a JPanel with paintComponent(Graphics g) and Graphics2D instance to carry out Java2D tasks.
StartJApplet5 Includes two JPanel instances. One panel - ControlPanel - provides for controls and implements the ActionListener interface. The other panel - OutputPanel - shows paintComponent() for drawing tasks.
StartJApplet6 Implements Runnable to provide for a thread process, such as for an animation on the applet. Includes overriden Applet class start() and stop() methods that start and stop the thread. Provides a JPanel sub-class (DrawingPanel) for graphics.
StartJApplet7 Use this starter to create your own applets that need a JTextArea object to display string info. Includes buttons "Go" and "Clear" to carry out programmer defined tasks. Also, it implements our Outputable interface, whose overriden print methods send strings to the text area.
StartJApplet8

Similar to StartJApplet7 but will run as an applet inside an application frame. The applet holds a text area to display string info. Includes "Go", "Clear", and "Exit" buttons to initiate processing and to clear the text area.

Optionally, it implements the Outputable interface so that secondary class can send print outputs to the text area.

StartJApplet9 This program can run either as an applet or an application. It also runs an applet inside a frame. Adds an applet to the frame of the application.
StartJApplet10

This program will run as an applet inside an application frame. The applet holds a text area to display string info. Includes "Go", "Clear", and "Exit" buttons to initiate processing and to clear the text area.

Optional Outputable interface. Remove the print, println methods if Outputable unneeded.

StartJApplet11

This program will run as an applet inside an application frame. The applet holds a GenericPanel class for output. Includes "Go", "Clear", and "Exit" buttons to initiate processing and to clear the panel area. Also, provides a JTextField component for text input.

Typcially, the GenericPanel will be replaced with a user defined JPanel subclass for graphics output.

StartJApplet12 This applet creates an instance of a JFrame subclass with a menu bar. (If the frame class gets much larger, put it into its own source file.)
StartJApplet13

Starter for a display with a split pane showing source image in left side and destination image on right. Need to enter the image file names.

Applications
Starter
Description
StartApp1 Basic application with just the main().
StartApp2
main() and one support class called Test.
StartApp3 main(), one support class called Test, which is extended by Test1, and then Test2 extends Test1.
StartApp4 main() and and an interface called Testable, which is implemented by two support classes - Test1 and Test2.
StartApp5

An application to hold an applet that needs an image, where the image name is passed via a command line argument. Need to add the method void initImg (String) to your applet class and use it to save the image name reference.

StartApp6 An application to create a ServerSocket object and spin off a threaded process to serve each client.
StartAppletViewer Frame subclass can implement the AppletStub and AppletContext interfaces to build an basic appletviewer. Here the getDocumentBase(), getImage(URL url), and getCodeBase() were implemented in detail. You will need to implement the other methods as needed.
With Swing Components
StartJApp1 Use this starter to create an application with a panel for image or other display.
StartJApp2 Use this starter to create frame that holds an applet. Here the applet cannot invoke the AppletContext methods such as getImage (). Use the StartJAppletViewer if the applet needs those methods.
StartJApp3 Provides a frame class with a menubar with a dropdown "File"menu for file opening and saving. Code for reading and writing strings also include.

A JFileChooser is provided to select file names for opening and saving. Also, included is HtmlFilter class to use with the FileChooser for selecting web pages. This can easily be modified to create a different filter to select for other file types.

The textarea here is only for demonstration. Replace the textarea with other components as required.

StartJApp4 Same as StartJApp3 but adds a JTextField and two buttons for entry and control.
StartJApp5 Same as StartJApp3 but no open/save file menu choices.
StartJAppletViewer Same as StartAppletViewer above except with Swing components. Use Start_JApplet9 for simpler approach to adding an applet to a app frame without implementing AppletStub and AppletContext interfaces
StartJAppletHolder Simpler version of the StartJAppletViewer that puts an applet into a frame but doesn't implement theAppletStub and AppletContext interfaces

 

  
  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.