| Author |
getting the text
|
ben riches
Ranch Hand
Joined: Nov 08, 2002
Posts: 126
|
|
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
Joined: Dec 12, 2002
Posts: 580
|
|
Try : ivjJTextField4.setText( String.valueOf( num ) );
|
 |
ben riches
Ranch Hand
Joined: Nov 08, 2002
Posts: 126
|
|
Originally posted by Don Kiddick: Try : ivjJTextField4.setText( String.valueOf( num ) );
Thanks Don that has worked fine Thanks agian ben
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
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.
|
 |
 |
|
|
subject: getting the text
|
|
|