You are along the right lines I think. You can use a NumberFormat and the setMaximumFractionDigits() and setMinimumFractionDigits() methods (same for the integer part).
The 'U' part is harder. What exactly is it used for? If it is a currency or something, you can use the setCurrency() method. If numbers always end in 'U' and nothing else, you might want to just consider ommiting it from the input. The worse is case is you might have to implement your own Format subclass.
You can then use this in conjunction with a JFormattedTextField.
Joined: Aug 02, 2005
okay i ignoreg the u.. and the list now is a list of number both (positive and negative ) and i want to check that i only have numbers?? what shall i do ..i tried to extract the charachters till i form a string and parse it and if there is an error in parsing i catch it this way i know that it is not the right input but i think it is stupid ..is there a better way?
Joined: Apr 21, 2005
I agree the solutions are not ideal. You can check out this page of the Java Tutorial to see if InputVerifiers might be better for you.