aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes setting integer to a textbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setting integer to a textbox" Watch "setting integer to a textbox" New topic
Author

setting integer to a textbox

mo robertson
Greenhorn

Joined: Mar 29, 2004
Posts: 24
ok i have an integer called 'Price' which has been declaired on a class
i want to set price to a textbox, but it doesnt let me becuase its integer, string works fine. how would this be ?

h[count].Price= "" + jTextField7.getText ();
Eddie Vanda
Ranch Hand

Joined: Mar 18, 2003
Posts: 281
Originally posted by mo robertson:
ok i have an integer called 'Price' which has been declaired on a class
i want to set price to a textbox, but it doesnt let me becuase its integer, string works fine. how would this be ?

h[count].Price= "" + jTextField7.getText ();


Hi mo,


Normally your integer would be called 'price' because only classes should be capitalized.

If your price can contain cents, then you can have a proble with decimal point.

What you will get from the text box, even if the user type all numeric digits, is an ascii string. You can call Integer.parseInt (jTextField7.getText ()) to convert it to an int. You can place that in a try/catch block in case the user did not type a convertable number.

Mo used to be a famous comedian in Australia over 50 years ago so I love your name.

Ed
[ May 21, 2004: Message edited by: Eddie Vanda ]

The nice thing about Standards is that there are so many to choose from!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting integer to a textbox