|
|
||
| You are here: | ||
|
A simple example using an array of TextFields and Labels. We re-visit the Applet to calculate resort temperatures set as a problem earlier on ( repetiton page ). Here the Labels hold the days and the TextFields are used to input the temperatures for each day. A Panel is used with a Grid Layout in 7 rows and two columns.
The use of libraries such as awt is a mastery aspect at SL. The use of arrays is a mastery aspect at SL.
Font name, style and size
setBackground can be applied to most awt components. Most constants in the Color class are easily guessed.
All text components can have fonts, foreground(font) colors and background colours set.
neat eh? sometimes I amaze myself!
Standard algorithm for summing numbers.
|
We also use this Applet to show some aspects of using Fonts, Colours and alignment of text. The Applet uses an array of Strings which is filled with data rather than declared as a fixed size. Any array can be initialised with values in this way: int[] arrayOfInt = new int[] {0, 2, 4, 7, 8, 9}; This automatically creates an arrray of sufficient size to hold the specified values.
Related: [ Java home | Previous: Arrays | Next: Array Operations ] |
Examples using 2D arrays of objects are on the next page. |
|
|
|||
|
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 |