• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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 ]
 
The longest recorded flight time of a chicken is 13 seconds. But that was done without this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic