6
Contributors
9
Replies
30
Views
10 Years
Discussion Span
Last Post by JamesCherrill
0

Second option is simpler. I thought I could be clever and discover something new, but it is not my day today :cheesy:
I will check user input with Character.isDigit() and kick of error message if anything wrong

0

I don't think so . . .
They are allow only to numbers but whole range of numbers, well zero onwards. Drop down box is good if you code calendar and don't know any other technique to do it(as their better then this) or you want to give them certaine values

0

I think that limiting user input is always good.

How about the JSpinner class. That should allow the user to input a large range of numbers (that you specify in the constructor).

0

You can use a javax.swing.JFormattedTextField with a java.text.NumberFormat as the format. For example:

numberField = new JFormattedTextField(NumberFormat.getInstance());
0

@peter budo The quickest solution is what titaniumdecoy suggested...Use a JFormattedTextField to restrict input to numbers. Not sure why some of the other solutions here contain a book of code to do such a simple task.

Edited by PupuPlatter: spelling

0

Hi P.P.
Welcome to DaniWeb
Did you notice this thread was marked "solved" 6 years ago? Your contribution is welcome, but it's far too late to be relevant.
JC

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.