Personal tools
You are here: Home Information Systems Java Platform Introduction 24. A Simple Demonstration

24. A Simple Demonstration

Document Actions
  • Send this
  • Print this
  • Content View
  • Bookmarks

A Simple Demonstration

<-- Previous

Table of Contents

Next -->

So far we have learned some of the essential basics of Java, and about some of the essential Java classes and their use. While what we've learned is not a great deal in the scheme of things, it is nonetheless still quite useful. There's an awful lot you can do with just these few classes and techniques. Even just the JOptionPane class allows us to build an application that uses the GUI for most of its interaction with the user.

Accessible from the links below in the page are two Java classes that in addition to the standard java.lang classes use only:

  1. javax.swing.JFrame
  2. javax.swing.JOptionPane
  3. java.lang.IllegalArgumentException
  4. the version of our Die class built for Ex. 6 B
  5. the console
to produce an application that plays a game of dice.

This game called Sevens displays the rules of the game in the console on startup, and then displays the progressive game scores in the console thereafter. All other interactions with the user take place through an instantiation of the JOptionPane class. To play the game, you need to download the two files below and save them in a folder. Access the folder with the console, and then type java Sevens to run the game. Note: You will need to have j2sdk1.4.2_03 or later to run the game.

Download Die.class & Sevens.class here.

Once you have played the game and seen how it works, you might like to take up the challenge of building the game - or something similar - for yourself!

<-- Previous

Table of Contents

Next -->

Copyright 2007-2008, by the Contributing Authors. Cite/attribute Resource. 24. A Simple Demonstration. (2008, July 16). Retrieved May 25, 2013, from UWC Free Courseware Web site: http://free.uwc.ac.za/freecourseware/information-systems/java-platform-introduction/a-simple-demonstration. This work is licensed under a Creative Commons License : Attribution-ShareAlike 3.0. Creative Commons License : Attribution-ShareAlike 3.0