Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-21-2008, 07:43 PM
Member
 
Join Date: Jan 2008
Posts: 3
teracomp is on a distinguished road
JFormattedTextField Issue
I'm using JFormattedTextFields to automatically manage several numeric text fields on an Applet. When the Applet's form is processed the data is collected from the form and written to a MySql database. Each text box is then set to blank, i.e., field.setText("").

So far, so good. However, if I click in the blank text box then click somewhere else, the value that was previously entered will reappear. This if very problematic.

I found the answer while preparing the post, but it might be useful to someone, so here's the solution.

The default behavior for losing focus is COMMIT_OR_REVERT
Apparently, the component recalls the last valid entry in the field when focus is lost. Sounds like a feature, but a big problem for me.

To fix this, I set the lost focus behavior for each field declared as a JFormattedTextField, e.g.: field.setFocusLostBehavior(JFormattedTextField.PER SIST);

Having said that, if anyone knows of a problem with this solution, please chime in!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-21-2008, 07:55 PM
Member
 
Join Date: Jan 2008
Posts: 3
teracomp is on a distinguished road
big OOPS! PERSIST is the wrong value; COMMIT is the proper way of handling this. Using PERSIST effectively short circuits the formatter (bad idea).

The code was changed to:
field.setFocusLostBehavior(JFormattedTextField.COM MIT);

And the behavior is what I required by default.

Still, let me know if anyone is aware of other JFormattedTextFields properties I should be concerned with . Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with Buttons and ActionPerformed Deathmonger Advanced Java 1 04-17-2008 09:47 AM
Try Catch issue curtis_fraser Advanced Java 2 12-14-2007 12:04 AM
Issue chaitu444 New To Java 2 11-06-2007 08:49 PM
Alignment Issue... chanduseec JavaServer Faces 0 08-13-2007 02:04 PM
compilation issue orchid Eclipse 2 04-20-2007 01:51 AM


All times are GMT +3. The time now is 07:05 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org