-
preventing JSpinners from taking non-positive integers
Hello,
I want to program a JSpinner such that the user cannot enter anything other than positive integers. As it stands now, a JSpinner is like a glorified JTextField in that the user can enter whatever characters (s)he wants. I'm using it to enter a person's age, so I want to prevent users from entering values like "abc". I'd much rather do this than implement sophisticated error checking once the user hits submit. Is there any example code online that shows how to do this? Can anybody tell me straight out how to do this?
Gibran
-
set the spinner model to be a SpinnerNumberModel bouded from 0 to MAX_INTEGER, starting at.. er.. 1?
read http://java.sun.com/j2se/1.4.2/docs/...mberModel.html
and try JSpinner.setModel(...)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks