Sine-wave example

A small example illustrating how a Swing-based GUI is built up. The application contains two threads: a sine-wave generator thread and a thread taking care of the plotting. The plotter thread is encapsulated in the class PlotterPanel (see documentation of local Java classes (se.lth.control.* ). Through the GUI it is possible to change the frequency and amplitude of the sine.wave. To illustrate the use of invokeLater the sinus thread detects a too large amplitude and in that case resets the amplitude. The code is extensively commented. The application is started from Main.

Class files

Documentation

If you are located at the EFD network the program is compiled using the following command:

javac -classpath .:/usr/local/regler/java/classes *.java

or, if you downloaded the regler.jar archive,

javac -classpath .:regler.jar *.java

The program is then executed by typing:

java -classpath .:/usr/local/regler/java/classes Main


Karl-Erik Arzen
Last modified: 2012-09-03