This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextField problem

 
Tony Shi
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I wnat to create a JTextField that accepts 0-9 only. I tried the following code,

it worked, but jTextField.selectAll() and jTextField.setText("String") stopped working. I can't seem to figure out the reason. Can someone please help?
Thanks a lot!
 
Jason O' Regan
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should implement a Document that only accepts numeric values,
by subclassing the javax.swing.text.PlainDocument class and overriding the insertString method there. Then add this Document to the JTextField using the setDocument method.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic