Link to University of Stirling home page Link to Computing Science and Mathematics home page
Link to University of Stirling home page
University | Computing Science | Modules | CSCU9A2 | Examples
CSCU9A2 Programming and User Interface Design Spring 2017
menu CSCU9A2 Spring 2017
Programming and User Interface Design


Module details
Materials Locked - username and password required for off-campus access
Assessment Locked - username and password require for off-campus access
Succeed Locked - username and password required


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 here.

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:

  1. Open the Java Control Panel from the Start menu
  2. Click on the Security tab
  3. The slider is probably set at High - leave it there.
  4. Beside the Exception Site List, click on Edit site list...
  5. Click on Add in the dialogue box
  6. Type     into the Location list, and click OK
  7. 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.

The examples

Most of the pages have links to run the application and/or fetch the Java source code itself.

  • 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)
The examples below were used in Spring 2013. They are less useful for Spring 2014.
  • 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
Contact Details
Module coordinator    Email - Room 4B63 - Tel 01786 467434
Mail Computing Science and Mathematics, School of Natural Sciences,
University of Stirling, Stirling, Scotland, FK9 4LA