Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2005

Tip: Looking for answers? Try searching our database.

JFormattedTextField inconsistent behavior

Thread view: 
Janene - 18 Nov 2005 22:02 GMT
I'm attempting to create a JFormattedTextField that will accept only a
certain set of characters, but there is not a limit on the length of
the string. I have put together a MaskFormatter like this (pardon any
typos, I'm having to type it in from scratch):

JFormattedTextField myFormattedTextField = new JFormattedTextField();
MaskFormatter mask = null;
try {
  mask = new
MaskFormatter("***************************************************************");
// yes, I know this has a length limit, but it's long enough
} catch (ParseException e) {}

mask.setPlaceholder("");
mask.setPlaceholderCharacter(' ');
mask.setValidCharacters"a really long string with all my valid
characters);
mask.setAllowsInvalid(false);
mask.install(myFormattedTextField);
myFormattedTextField.setFormatter (mask);

When I run this, sometimes it rejects invalid characters, and other
times it allows them to be typed. I cannot figure out the logic of when
it does and does not - sometimes I initalize it to a valid string,
other times leave it blank, but this doesn't seem to have a bearing on
anything. Also, sometimes it's backfilled with spaces and sometimes
it's not. This is just not a hard thing to do, surely, I hope I am
missing something simple.

Thanks in advance for any pointers.

Janene
jonck@vanderkogel.net - 20 Nov 2005 23:33 GMT
> When I run this, sometimes it rejects invalid characters, and other
> times it allows them to be typed.

I  have no idea what could be causing these symptons, though I'm sure
if you post a SSCCE (http://www.physci.org/codes/sscce.jsp) we'll be
able to get to the bottom of it.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.