wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes reading from TextField Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "reading from TextField" Watch "reading from TextField" New topic
Author

reading from TextField

Dominik Pawlocki
Greenhorn

Joined: Oct 31, 2001
Posts: 6
How can I read the string entered in my window's TextField or TextArea after the Enter is pressed?
I know how to use the KeyListener to Enter pressing detect,but I don't know how to read this text from my TextField.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

yourTextField.getText() - Returns a String();
You may want to do a little studying of the JAVA API. Have you? It is in there.

------------------
Happy Coding,
Gregg Bolinger


GenRocket - A Test Data Generation Platform
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
TextField generates an ActionEvent and notifies all of its ActionListener when the RETURN key is typed. So in order to be notified your class should implement the ActionListener interface (i.e. implement the public void actionPerformed(ActionEvent e) method). Then to get what has been typed, you just have to invoke getText() upon your TextField instance and that's it...
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Michael Bruesch
Ranch Hand

Joined: Sep 23, 2001
Posts: 158
Or you can set it as a TextListener and it will fire an event everytime a character is entered in the textfield. Depending on what you need your textfield to do that is.
------------------
Michael J Bruesch
Codito, ergo sum...
I code, therefore I am.
My Java Games, I'm quite proud


Michael J Bruesch<br /><i>I code, therefore I am.</i>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reading from TextField
 
Similar Threads
output in a textfield.
Checking value of one textfield matching the other
transfering focus with enter key
<sx:tabbedpanel with textbox issue
Key listener or what?