Home arrow static arrow Java Programming [Archive] - Texfield to variable
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Texfield to variable
This topic has 1 reply on 1 page.

Posts:67
Registered: 2/8/04
Texfield to variable  
Aug 6, 2004 11:22 PM



 
I have a textfield called txtTime and I want the number in the textfield to go into a variable called time but I don't want it to be a string, I need it to be an integer. I'm not exactly sure how to do this.
 

Posts:1,135
Registered: 1/16/04
Re: Texfield to variable  
Aug 6, 2004 11:48 PM (reply 1 of 1)



 
I have a textfield called txtTime and I want the number in the textfield to go into a variable called
time but I don't want it to be a string, I need it to be an integer. I'm not exactly sure how to do this.

You can use the Integer wrapper classes parseInt() method to get your integer out of the textfield...

example...
int integerVariable = Integer.parseInt(textFieldVariable.getText());


Check the API specs for usage and further information, such as which exceptions may get thrown...

- MaxxDmg...

- ' He who never sleeps... '
 
This topic has 1 reply on 1 page.