This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Making JTextField accept an INT? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Making JTextField accept an INT?" Watch "Making JTextField accept an INT?" New topic

Making JTextField accept an INT?


Joined: Oct 24, 2005
Posts: 15
Is this possible?

I'm trying to use the set text method to put an integer value in a JTextField and getting the incompatibility error, is this possible or is there another method I'm not aware of?
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
you could use:





myTextField.setText("" + myInt);

Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
You can use String.valueof(integer), or use java.text.DecimalFormat's format method if you want commas added: 12,333 etc...

There is no emoticon for what I am feeling!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Making JTextField accept an INT?
It's not a secret anymore!