• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

setting integer to a textbox

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ();
 
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
this is supposed to be a surprise, but it smells like a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic