Is there any way to accept only double values in a JTextField using documentfilter?
Asked
Active
Viewed 6,403 times
0
-
1I'm a little confused at what you mean. Do you mean they could enter any number? Thats just a sequence of digits with one optional dot and an optional plus or minus on the front. Or is there more you want? – Lee Meador Mar 07 '13 at 20:14
-
Does an `int` or a `float` count as a `double`? – ApproachingDarknessFish Mar 07 '13 at 20:20
1 Answers
4
You will want to use a DocumentFilter
This will allow you to "filter" the incoming content before it reaches the document.
Check out these examples for more ideas
You could also try look at a JFormattedTxtField
which would probably be easier, but where's the fun in that

MadProgrammer
- 343,457
- 22
- 230
- 366
-
-
Check out the examples links, hey are better then nothing I could post – MadProgrammer Mar 17 '13 at 21:06