The Artima Developer Community
Sponsored Link

Java Answers Forum
Masking in Java

2 replies on 1 page. Most recent reply: Nov 9, 2002 10:19 PM by twisty

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
ashar

Posts: 11
Nickname: asharjaved
Registered: Nov, 2002

Masking in Java Posted: Nov 9, 2002 5:58 PM
Reply to this message Reply
Advertisement
Is there anybody who can help me how to perform masking in Java.Please send some code of doing this.thanx


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Masking in Java Posted: Nov 9, 2002 7:52 PM
Reply to this message Reply
Masking is a pretty general term, maybe you could elaborate a little. Are you talking about having an edit control that only allows certain formats to be typed into it?

twisty

Posts: 22
Nickname: twisty
Registered: Nov, 2002

Re: Masking in Java Posted: Nov 9, 2002 10:19 PM
Reply to this message Reply
I presume that your trying to create something like a password field, or something similar? If your using 1.4, its a simple matter of creating a JFormattedTextField with a MaskFormatter.
MaskFormatter maskFormatter = new MaskFormatter("####-####");
JFormattedTextField jftf= new JFormattedTextField(maskFormatter);

In the example above, the user is presented with a textfield that only allows numbers to be entered (____-____). Some other mask charachters are:

? - letter
A - number/letter
H - hexadecimal
L - lowercase
U - uppercase
* - anything
' - escape charachter

In earlier versions of swing you can extend the PlainDocument class so that you can then use the setDocument method for your textfield to use your custom PlainDocument. If you don't know how to do this, feel free to ask.

Flat View: This topic has 2 replies on 1 page
Topic: cadServer.java:53: unreported exception java.net.MalformedURLException; mus Previous Topic   Next Topic Topic: BufferReaders

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use