Basic HTML version of Foils prepared March 26 1999

Foil 7 TextFields

From Java Academy:Graphical User Interface NPAC Java Academy February--April 99 -- March 1999. by Nancy McCracken


1 A TextField is a box in which the user enters a single line of text: TextField tf = new TextField ( 30 ) ;
2 The argument is an integer giving the width of the TextField in characters.
3 TextFields have methods either to get the text that a user typed in, or to write some text in the box: String word1 = tf.getText ( ) ; tf.setText ( "Thanks!" ) ;
4 Note that when the user presses enter, a TextField can also generate an ActionEvent, but it is generally better user design to respond to button events.

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Fri Mar 26 1999