Driver for Gallery

Summary

This is not a demonstration of the JMSL Library. Instead, it is a possible useful application that parses a list of the JMSL Gallery Demos in xml format and creates a menu of buttons. The code for the description window, that each example application fills with HTML to describe the functionality and usage of that demo, is included in this package.

Usage

The demo starts by parsing an xml list of gallery examples. A JButton for each valid application is created in the user interface and an initial description window is created.

Java Code

The description window is used by each example to pass information about itself to the user. This window contains a JEditorPane with its content type set to accept html: setContentType("text/html").

To spawn the individual demos, the main class name is supplied in the xml list of applications. Once that is parsed, the main method of the selected class is called with the "-noexit" argument to instantiate the class.

if (classMain == null) classMain = Class.forName(main);
String
argsMain[] = {"-noexit"};
Method
methodMain = classMain.getMethod("main", new Class[]{argsMain.getClass()});
methodMain
.invoke(null, new Object[]{argsMain});

Links to Source Code

Driver.java This is the main class for this demo. It is a JFrame that contains the JButtons created from the list of demos.
Binding.java This class is used to parse the xml file containing the list of demos.
Demo.java This class is called from Binding and helps to put the demo list in a useful context.
Describe.java The JDialog contains an JEditorPane that accepts HTML for display. It is called by Driver.java and the main class of every example application.

Running This Demo

Two alternatives are available to run this driver for the demo gallery:

1) Use the source code in your development environment as any other Java code. More information is available in the How To.

2) An executable jar file containing all of the demos referenced in this guide is included in the jmsl/lib directory. On Windows, you may double-click the file to run it if files with a ".jar" extension are properly registered with javaw.exe. Alternatively, for both Windows and UNIX environments, the jar file may be executed from the command line using java -jar gallery.jar.

As list of buttons, one for each demo, is created. Demos can be subsetted as they relate to specific areas (Math, Stat, Finance, Charting) by choosing the appropriate selection on the JComboBox. To run the Additional Demos, select Quick Start in the JComboBox.