CISC370-011 --
demo code from class #6
This page provides links to some short demo programs
from class #6 (14 Oct):
-
Text1.java is a very simple
demonstration of the JTextField class.
-
Text2.java shows how a
DocumentListener can be hooked up to a
JTextField.
-
Check1.java demonstrates the
JCheckBox class.
-
Radio1.java demonstrates the
JRadioButton class.
-
BoxDemo.java illustrates the
Box layout object. It also shows the use of the
BorderFactory class to decorate Swing components.
-
Label1.java demonstrates
JLabel's capabilities, including its ability to
display images and HTML text.
-
ComplexMenu.java demonstrates
complex menu items with the
JCheckBoxMenuItem and
JRadioButtonMenuItem classes.
-
Combo1.java is an example of a
simple JComboBox.
-
TFormat1.java shows a simple
example of JFormattedTextFields
using a DefaultFormatter and a
MaskFormatter.
-
ColorNames.java demonstrates
a JTextArea inside a JScrollPane.
-
FileSelect1.java demonstrates
the JFileChooser class by implementing a simple
image display program.
The extended example of the Strategy pattern
was an ODE (Ordinary Differential Equation) solver/problem.
The test code defines a Traject ODE according to the
ODE pattern, then creates an ODESolver object
of class Euler to integrate the ODE. The example
uses JFreeChart to draw the resulting family of curves.
The source files are:
-
TrajectApp.java --
The main program.
-
Traject.java --
The Traject class, that represents a 2D
ballistic trajectory with drag.
-
ODE.java --
The interface which any ODE problem should implement.
-
ODESolver.java --
The interface which any ODE solver should implement.
-
Euler.java --
Implements the ODE interface.
Note that this is a very poor integrator! Don't
use it to solve real problems; use Runge-Kutta,
predictor-corrector, or something better instead.
And the output from the program is: