|
|
||
| You are here: | ||
|
PressMe.Java A starter Applet which uses the awt (abstract windows toolkit).
Explanations statements which import special Applet Classes Comments in blue are ignored by the compiler - the program that turns Java language to machine code. PressMe is the name I chose for this Class. These are graphical user interface (gui) objects imported with java.awt.*
An init method is needed by any subclass of the Applet Class - this Class is a subclass (it extends Applet), Applet is the superclass.
ActionListener is an interface implemented by this Class.
This method is required by the ActionListener interface. ActionEvent is a Class defined in the ActionListener interface. setText and getText are methods of the Label and TextField Classes. |
If you can't see an Applet here, download the JRE from http://www.java.com . It's free and easy to do. Otherwise cut and paste the code into your favourite editor.
Source code: PressMe.java
/** Related: [ Java Home | previous:getting started | next:some elements of syntax ] |
Teaching notes: There is quite a lot to take in here for the first-time student. Don't try to explain everything at once - deal with the questions as they arise. There is a lot to be gained by allowing the students to change various bits of code to see what happens. After experimentation, maybe get them to print out the Applet window and cut & paste the relevant code sections to see the connections. |
|
|
|||
|
Questions or problems related to this web site should be addressed to Richard Jones who asserts his right to be identified as the author and owner of these materials - unless otherwise indicated. Please feel free to use the material presented here and to create links to it for non-commercial purposes; an acknowledgement of the source is required by the Creative Commons licence. Use of materials from this site is conditional upon your having read the additional terms of use on the about page and the Creative Commons Licence. View privacy policy. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. © 2001 - 2007 Richard Jones, PO BOX 246, Cambridge, New Zealand; This page was last modified: July 29, 200823, 2008 |