Link to University of Stirling home page Link to Computing Science and Mathematics home page
Go back Go back

Java application examples

Some of these come from "Java for Students", 4th edition, by Bell & Parr, indicated by "B&P". Extensions and extras mostly by Simon Jones, indicated by "SBJ".

In order to launch the runnable versions it is necessary to have installed the JavaWebStart product from Sun. This is installed as part of a JDK installation, or may be fetched separately from here.

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

  • Hello: Displays a simple greeting in a pop up box (B&P)
  • Greeting: Displays a simple greeting in a text field (B&P)
  • DrawExample: Draws a single line when a button is pressed (B&P)
  • SomeShapes: Displays several graphical shapes on the screen (B&P)
  • AreaCalculation: Displays the result of a simple calculation in a dialogue box(B&P)
  • AreaDialogs: Uses dialogue boxes to prompt for the input of a length and a width, and then displays the result of the area calculation in a dialogue box (B&P)
  • LogoMethod: Displays two simple logos on the screen, using a method (B&P)
  • TriangleMethod: Displays two simple logos and two triangles on the screen, using methods (B&P)
  • HouseDemo: Displays two simple lean-to houses on the screen, using methods (B&P)
  • AreaMethod: Displays the result of a simple calculation in a dialogue box, but using a non-void method (B&P)
  • CarCounter: Increments a counter each time a button is pressed, and displays the result in a dialogue box (B&P)
  • CarCounter2: Increments a counter each time a button is pressed, and displays the result in a text field (SBJ)
  • CarCounter3: Increments a counter each time a button is pressed, and displays the result in a graphics panel - but without clearing the panel first (SBJ)
  • CarCounter3b: Increments a counter each time a button is pressed, and displays the result in a graphics panel - but properly clearing the panel first (SBJ)
  • SimpleSlider: The value selected by a simple slider is displayed in a text field (SBJ)
  • WindowBlind: Displays a window with blind adjustable by a slider (B&P/SBJ)
  • Safe: Only unlock the safe if the correct number is entered (B&P)
  • Voting: Tell user whether they can vote or not, based on their age (B&P)
  • SimpleShopSign: Control a shop sign: Open/Closed (B&P/SBJ)
  • ShopSign: Control a shop sign: On/Off/Open/Closed (B&P)
  • DiceTotal: Display two sliders and total of dice (SBJ)
  • QuickBlind: The WindowBlind example with quick "Open" and "Close" buttons (SBJ)
  • SwitchDay: Displays messages describing the day selected by a slider (B&P/SBJ)
  • TenBoxes: Draws ten boxes (B&P/SBJ)
  • Boxes: Draws boxes - number selected by a slider (B&P/SBJ)
  • Squares (interactive): Displays the squares of numbers entered by the user until a -ve is entered (SBJ)
  • Squares: Displays square numbers, up to a limit entered in a text box (B&P/SBJ)
  • BoxesFor: Draws boxes using a for loop (SBJ)
  • SumUp: Displays the sum of integers in a range (SBJ)
  • Drunk: Displays a random drunken walk(B&P/SBJ)
  • Lottery: Displays two random lottery numbers (B&P)
  • Apartments: Draws an apartment block (B&P)
  • Band: Displays the names of the Beatles (from an array) (SBJ)
  • Rainfall: Manages a table of rainfalls for a week (B&P/SBJ)
  • JumpingWorld: Message moves with mouse clicks (SBJ)
  • OvenGuide: Shows temperature zones (SBJ)
  • Censor: A simple text censoring application (SBJ)
  • ExceptionDemo1: A simple demonstration of unhandled exceptions (SBJ)
  • ExceptionDemo2: The same, but with the exceptions handled using try/catch (SBJ)
  • AreaDialogsSafe: Like the AreaDialogs example, but catches NumberFormatExceptions due to faulty data entered, and gives sensible warnings, repeating the inputs until valid data is entered. (SBJ)
  • Database: A simple database for one student - naive version (SBJ)
  • Database: A simple database for one student - object oriented version (SBJ)
  • UseBalloon:Displays a balloon and allows size adjustment - uses an extra Balloon class (B&P)
  • QuickBlind: but doing screen refreshes properly (SBJ)
  • SimpleGardenDesign: Add trees with mouse clicks (SBJ)
  • GardenDesign: More advanced garden design: Add and delete trees with mouse clicks (SBJ) (also has more interesting internal workings: a TreeList class, an enum type, Graphics2D antialiasing for smoother drawing)
  • A demonstration of AWT CardLayout
  • Image drawing

Go back Go back

If you have any difficulties accessing this page, or you have any queries/suggestions arising from this page, please email:

Link to Computing Science and Mathematics home page
© University of Stirling 2018           Last updated: Thursday, 18-Mar-2010 22:29:59 GMT
The University of Stirling is a charity registered in Scotland, number SCO11159