Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting the text

 
ben riches
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I have a int called num which holds the number 10 in it, and I want my text field to display the ints value.
I have tried this:

what am I doing wrong?
Thanks
ben
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try :
ivjJTextField4.setText( String.valueOf( num ) );
 
ben riches
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Don Kiddick:
Try :
ivjJTextField4.setText( String.valueOf( num ) );


Thanks Don that has worked fine
Thanks agian
ben
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben,
Just to elaborate a bit on what Don posted, the Java API is your friend.
If you look at the API for JTextField you will notice that the method setText() takes a String as an argument. You tried to pass it an int, hence, the compilation error. Also, look closely at compliation errors. They are pretty good, though not always, about telling you what the problem is.
I only say all this because it can save you a tremendous amount of time waiting for people to reply to your posts. I also say this because I wasn't sure if you knew the reason WHY what you were doing didn't work.
I am imfamous for just getting things to work and not caring WHY it works or didn't work. After 4 years of Java programming, I am now trying to break that habit and learn more about WHY than just accepting that things work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic