Forums Register Login

NX:Formatted textField

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Hi Manoj,

And then set the document to your textfield.
Best,
Vlad
+Pie Number of slices to send: Send
Use regular expressions to check if the entered value is valid. If not pop a message saying what is expected from the user.
Arun
+Pie Number of slices to send: Send
try this:
this.bookField = new JFormattedTextField(new
MaskFormatter("########"));
bookField.setFocusLostBehavior(JFormattedTextField.PERSIST);
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
Can somone help me out
+Pie Number of slices to send: Send
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
Liar, liar, pants on fire! refreshing plug:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


Reply locked
This thread has been viewed 804 times.
Similar Threads
How to check given field whether primitive or user defined
Tabs within one browser share Session, but I want to capture close and time out event for each tab
Help code problem please
customized Marker interface
How can I read a single character from keyboard as soon as typed?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:42:20.