Re: Formatted text field
From: Andrew Thompson (andrew64_at_bigNOSPAMpond.com)
Date: 12/20/03
- Next message: Michael Pitoniak: "Re: BeanShell Interpreter ImportCommands() Problems"
- Previous message: gajo: "Re: Conversion troubles"
- In reply to: John M: "Formatted text field"
- Next in thread: ak: "Re: Formatted text field"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 20 Dec 2003 18:57:19 GMT
"John M" <bali1a@freemail.hu> wrote in message
news:hsXEb.151792$dt3.78933@news.chello.at...
> Hello,
>
> how is it possible to enable only numbers input in a jFormattedTextField?
> I use now this code:
> JFormattedTextField jFormattedTextField1 = new JFormattedTextField(new
> DecimalFormat());
>
> But in this case user can enter any character and the decimal conversion
> comes after leaving the cell.
> I want that user can enter only digits.
Som is '-1' valid for your field, it is an integer,
but does not consist of only digits..
If you _only_ need digits, you might try this..
Add a keylistener to a textfield. Parse the
contents as an integer on each keypress, if
that throws an exception get the text of the
field, trim it by 1, put it back and inform the user..
[ This has some problems if the user types
987, then arrows back 9 and types a,
but I think you get the idea.. ]
HTH
-- Andrew Thompson * http://www.PhySci.org/ PhySci software suite * http://www.1point1C.org/ 1.1C - Superluminal! * http://www.AThompson.info/andrew/ personal site
- Next message: Michael Pitoniak: "Re: BeanShell Interpreter ImportCommands() Problems"
- Previous message: gajo: "Re: Conversion troubles"
- In reply to: John M: "Formatted text field"
- Next in thread: ak: "Re: Formatted text field"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|