aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes String to integer?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "String to integer??" Watch "String to integer??" New topic
Author

String to integer??

tiffany ng
Greenhorn

Joined: Mar 29, 2003
Posts: 3
hi everyone,
hmm i'm doing a swing applet and i have trouble getting the int from the text field...
for example :
JTextField textField = new JTextField(10);
when lets say if someone key in numbers in this text field will i be able to retrieve the number from the String(i suppose textField.getText() is to get the value in the text field right?and it is a String..)
i've look thru java API and it says that i can convert a String to an integer by using parseInt or decode right?but how do i use it?
thanks
Gary McGath
Ranch Hand

Joined: Mar 15, 2003
Posts: 52
You need to use Integer.parseInt(). Don't forget to catch parsing exceptions.


http://www.mcgath.com/consulting/
tiffany ng
Greenhorn

Joined: Mar 29, 2003
Posts: 3
oh thanks a lot~
YES!it works!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String to integer??