*
The moose likes Beginning Java and the fly likes Field text not returning Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Field text not returning" Watch "Field text not returning" New topic
Author

Field text not returning

Maja Gralewska
Ranch Hand

Joined: Sep 26, 2008
Posts: 92
Hi, i'm trying to get a value from a text field after it has been edited but when ever i run the code it returns blank even if there is text edited it there. The first time you log in there is a default value but it can be edited.




Any ideas on why it doesn't return a value would be greatly appreciated.
Thanks

(Jesper Young: Fixed code tags)


Potrzeba jest matka wynalazków
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Do void methods ever return a value? And please use the CODE button rather than writing tags by hand.
Maja Gralewska
Ranch Hand

Joined: Sep 26, 2008
Posts: 92
I don't understand, i don't want to send the value to another method or anything like that i just want to print the value that the user inserts?

thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Well, that is what "return" means.

If you want to print it out, it is worth checking whether the if condition is ever satisfied.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
possibly you have agentCodeF declared twice:
once as a class field - the one referenced by the listener
also as a local variable, local to the constructor (or whatever method you build the gui) - this is the one you see on the screen

remove the duplication, and agentCodeF.getText() should return it's value
 
jQuery in Action, 2nd edition
 
subject: Field text not returning
 
Similar Threads
capturing variable in "value" field of the form
onClick() to clear text field
update only 5th incrementt value into databse
update only 5th incrementt value into databse
problem in reset() function