Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getText from the textField

 
Bin Wu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hava a question about the TextField as follows, should be relative to String accurately.
String typedString = textField.getText();
How can I to transfer the typedString to primitive int? I must code myself or can get the result through the java library directly? Thanks in advance.
 
Paul Smiley
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry to say this, but you must parse it yourself...
 
Andrew Spruce
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the value may be a non-numeric character it is sensible to do this anyway,
I think there are static methods of the Number classes like Interger.parseInt(String s) or Double.parseDouble(String s) that throw a number format exception if the string evaluates to number that is out of range or is not a number at all.
Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic