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 | ITNP001 | Code examples and demonstrations
ITNP001 Principles and Practice of Programming Autumn 2017
menu ITNP001 Autumn 2017
Principles and Practice of Programming

Home

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

 

Code examples and demonstrations

In order to launch the runnable versions it is necessary to have installed the Java WebStart product from Oracle. This is installed as part of a standard JDK/JRE 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.

Note: Due to recent increases in security requirements by the JVM when running Java from the Web, the runnable versions on the following pages will probably not work for you. It will be necessary to download the source code of the examples, then compile and run.

Programming Concepts

Most of the following come from the course textbook, roughly in the order that the Java concepts are dealt with in the book. Extensions and extras are from Simon Jones.

  • 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)
  • TenBoxes: Draws ten boxes (B&P/SBJ)
  • Boxes: Draws boxes - number selected by a slider (B&P/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)
  • ApartmentsSlow:Draws an apartment block slowly (B&P/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)
  • UseBalloon:Displays a balloon and allows size adjustment - uses an extra Balloon class (B&P)
  • QuickBlind: but doing screen refreshes properly (SBJ)
  • JumpingWorld: Message moves with mouse clicks (SBJ)
  • SimpleGardenDesign: Add trees with mouse clicks (SBJ)
  • OvenGuide: Shows temperature zones (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)

Structures in Java


Updated 27/11/15 14:01
Contact Details
Module coordinator    Email - Room 4B63 - Tel 01786 467434
Mail Computing Science and Mathematics, Faculty of Natural Sciences,
University of Stirling, Stirling, Scotland, FK9 4LA