OK, so now you've got a TextField, and you're wondering what you can do with it. Well here's one thing: you can use it to determine what gets printed to the system console. All you need is a variable and a way of getting the text from your TextField. Here is how its done:
A) just above your constructor, add a String variable, like so:
String sayWhat;
B) just before f1.show( ), add this line to make this variable empty:
sayWhat=""; //empty string
C ) Inside your actionPerformed statement, add these two lines:
sayWhat = typeText.getText( );//get the text in textfield
System.out.println(sayWhat); //pass it to console
this takes whatever you've typed into the TextField, and then passes that stuff to your String variable. This String is then sent to your system console
voila!
Uncle Paulie
Wednesday, February 4, 2009
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment