|
|
||
| You are here: | ||
|
This Applet simply demonstrates use of a couple or three GUI objects from the awt that you might find useful in future programs. You can see some of their methods here. For more try the Java 1.4.2 Documentation set at: http://java.sun.com/j2se/1.3/docs/api/index.html Click on the awt link and then the Class that you want more information on. For example, select Choice then see the documentation for the constructor and the method add(String) that we used in the following example.
New objects: The Checkbox - like a radio button, you can select it on or off. You can place Checkboxes in a CheckboxGroup - in which case selecting one button automatically de-selects any others. The Choice - like a drop-down list, you can click and select items listed. The TextArea - a bigger version of the TextField with multiple lines and scrollbars. Notice the Checkboxes being associated with the CheckboxGroup:
We can set the size of the Applet window:
We manually add the choices to the Choice list:
We append (add) a line to the TextArea Each time the button is pressed, data from the GUI objects is collected and displayed in the TextArea. Notice the multi-line layout. getSelectedCheckbox() is a method of the CheckboxGroup Class . |
Source code: Gooey.java import java.applet.Applet; /**
|
GUI - graphical user interface |
|
|
|||
|
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 - 2009 Richard Jones, PO BOX 246, Cambridge, New Zealand; This page was last modified: May 31, 2009 |