Results 1 to 2 of 2
Thread: JFormattedTextField Issue
- 01-21-2008, 06:43 PM #1
Member
- Join Date
- Jan 2008
- Posts
- 3
- Rep Power
- 0
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!
- 01-21-2008, 06:55 PM #2
Member
- Join Date
- Jan 2008
- Posts
- 3
- Rep Power
- 0
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.
Similar Threads
-
Alignment Issue...
By chanduseec in forum JavaServer Faces (JSF)Replies: 1Last Post: 09-30-2008, 06:47 AM -
Issue with Buttons and ActionPerformed
By Deathmonger in forum Advanced JavaReplies: 1Last Post: 04-17-2008, 08:47 AM -
Try Catch issue
By curtis_fraser in forum Advanced JavaReplies: 2Last Post: 12-13-2007, 11:04 PM -
Issue
By chaitu444 in forum New To JavaReplies: 2Last Post: 11-06-2007, 07:49 PM -
compilation issue
By orchid in forum EclipseReplies: 2Last Post: 04-20-2007, 12:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks