Parents : Curriculum : ICT
6th Form ICT
Creating GUIs with user interaction
Computers are only useful if they can be used, and interacted with by their users. The way
in which you interact and send information to any computer that you use is by using a
Graphical user interface (GUI), and normally a mouse.
In this short introduction you will produce a GUI that looks like this:

Fig 1 Finished GUI
You can see that the GUI has buttons on it, and as we program the GUI you will see what
interactions can be used, and how those interactions are implemented in code. At various
points you will be given code samples which you need to type into the program.
The applications you will use to produce this code are Notepad, and Command prompt, both
of which can be found in the accessories part of the Windows XP program menu.

Fig2
Creating the initial GUI from the sample code
The first thing you need to do is copy the code from here. The code needs to be saved locally
in a file called SwingApplication.java.
To compile the code you need to use a command window, and change into the directory that you have saved
your SwingApplication.java file.
To change directory in a command window at the command prompt you type
cd - to change directory
Dir - to find out what files or directories are in your curent directory
For example

Fig 3
To change into the My Documents directory you need to type
C:/> cd My Documents

Fig4
Compile this code by typing. Compiling the code translates it into a type of code that computers
understand called machine code.
C:/> javac SwingApplication.java
If this compiles you should find that your directory has:
SwingApplication.java
SwingApplication.class
To run the GUI you use the command
C:/> java SwingApplication
If you have any problems, just ask for help. Then move onto making the GUI interactive.
|