Java programming examples and demonstrations
In order to launch the runnable versions of programs on this page, it is necessary to have installed
the Java WebStart product from Sun. This is installed as part of a JDK
installation, or may be fetched separately from
You will also almost certainly need to relax your Java installation's security restrictions a little in order to
run the programs. Here are the instructions for a Microsoft Windows environment:
- Open the Java Control Panel from the Start menu
- Click on the Security tab
- The slider is probably set at High - leave it there.
- Beside the Exception Site List, click on Edit site list...
- Click on Add in the dialogue box
- Type http://www.cs.stir.ac.uk into the Location list, and click OK
- Accept/continue past any security warnings, then click on OK in the Java Control Panel
Once you have done this, you may still need to accept some security warnings when you launch the example programs.
Most of the pages have links to run the application and/or fetch the Java
source code itself.
The examples below were used in Spring 2013. They are less useful for Spring 2014.
- CarPark: Increments and decrements a counter to track cars entering and leaving a car park,
and displays the number of cars currently in the car park in a textfield
- SimpleSlider: A slider allows the user to select a number in the range -200
to 2000, and displays the number in a textfield
- WindowBlind: Adjust a window blind with a slider
- SelectionSort: Displays a
random int array and then the selection sorted version (Horstmann)
- SelectionSortWithTimer: Prompts for an array size,
then generates a random array, sorts it and displays the time taken (Horstmann)
- EmptyFrame: Displays a simple empty Swing JFrame (Horstmann)
- FilledFrame: Displays a simple Swing JFrame with a button and a label (Horstmann)
- ChartComponent: Displays a simple bar chart using AWT Graphics (Horstmann)
- ChartComponent2: Displays a simple annotated bar chart using AWT Graphics (Horstmann)
- InvestmentFrame3: Displays successive balances in a text area as an investment grows (Horstmann)
- InvestmentFrame4: Displays successive bars as an investment grows (Horstmann)
Updated 10/04/14 16:02