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

Andrew Su asu at redhat.com
Mon Feb 28 11:35:23 PST 2011



----- Original Message -----
> From: "Deepak Bhole" <dbhole at redhat.com>
> To: "Andrew Su" <asu at redhat.com>
> Cc: "Deepak Bhole" <dbhole at redhat.com>, "IcedTea" <distro-pkg-dev at openjdk.java.net>
> Sent: Monday, February 28, 2011 12:27:45 PM
> Subject: Re: [RFC][Icedtea-Web]: Ensure all ports entered are numeric values
> * 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

Ok, I tested MaskFormatter, which does check on input, but it seems to prepopulate the textfield with blank spaces. If the user clicks the end of text they can't input anything. and in the even that they don't enter the number of digits requested, it is deemed invalid and won't record that field.

Similarly, when losing focus a check to see if it follow the format happens and then reverts back to last valid entry. The user could still enter 1 [right arrow] 2 [right arrow] etc, which of course will revert to last valid entry.

Regards,
  Andrew


> 
> Cheers,
> Deepak



More information about the distro-pkg-dev mailing list