Hi Could someone please post an example of formatted text field to validate user input? (using Document )(for example, just to take 8 numbers from user) Thanks, Manoj
Vlad, thanks for the code. It helped me to grasp the concept too. But later I realized that this will not solve my problem, as I am using JOptionPane.showInputDialog. This was a very easy option. But as this shows its own default textfield, I could not find a way to setDocument to it's default textfield. If I try to add a new textfield to this, it shows 2 text field, one my own and 2nd it's default one. Is there any way to set the Document to the showInputDialog's default textfield? I could not find anything in the API. The other option to create the customized optionpane involves too much of code, which I dont want to do just for this small purpose.
And thanks to Bill too for the code snippet. I guess now instead of setDocument one could (or should) use the JFormattedTextField, as this is in the new API (1.4) I am not sure if it is ok, when one says that his/her assignment is developed on the latest version (like 1.4.1 or 2) and still use the setDocument and not the JFormattedTextField. Thanks, Manoj [ October 07, 2003: Message edited by: Jmannu gundawar ]
Manoj, I have closed this topic. It seems you are asking the same question in this one as you asked in the topic "Book Number text field In this thread Vlad has been kind enough to post code showing how to use a Document to validate the field. In the other thread Mark has been kind enough to post code showing how to validate the field. In both threads Bill Robertson has been kind enough to show how to use the JFormattedTextField and MaskFormatter (assuming you are using J2SE 1.4 - which you should be doing). So there is nothing in this thread that is not in the other thread. The other thread has some other items of interest to those doing the Fly By Night Services assignment, so I am leaving that one open. Regards, Andrew
Post by:autobot
Liar, liar, pants on fire! refreshing plug:
a bit of art, as a gift, that will fit in a stocking