[RFC][Icedtea-Web]: Ensure all ports entered are numeric values

Deepak Bhole dbhole at redhat.com
Mon Feb 28 09:27:45 PST 2011


* Andrew Su <asu at redhat.com> [2011-02-28 11:56]:
> 
> 
...
> > > I meant that if the value entered is invalid it gets cleared. Of
> > > course this behaviour can be changed, but iirc it only does the
> > > check after the focus to the JFormattedTextField.
> > >
> > 
> > Ah, but JFormattedTextField wouldn't allow invalid values in the first
> > place, so there should be nothing to clear.. or am I missing
> > something?
> 
> Here's what I did to test it: http://fpaste.org/Y4cy/
> 
> Steps:
>   1. Enter some non-numeric value.
>   2. Click button (to lose focus on text box). [Should get cleared]
>   3. Clear field then enter some digits.
>   4. Click button (to lose focus on text box). [Should have no change]
>   5. Add some non-digits to the field.
>   6. Click button (to lose focus on text box). [Should revert back to value at #4]
>   7. Remove all items in the field.
>   8. Click button (to lose focus on text box). [Reverts back to value at #4]
> 
> --Andrew
> 

Ah, I see what you mean now. In that case, take a look at MaskFormatter:
http://download.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html#maskformatter

Cheers,
Deepak




More information about the distro-pkg-dev mailing list