wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Custom MaskFormatter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Custom MaskFormatter" Watch "Custom MaskFormatter" New topic

Custom MaskFormatter

J Wallace

Joined: Jan 30, 2008
Posts: 5

I am trying to create a MaskFormatter that formats an elapsed time. The number of elapsed seconds is stored as a Double and should be formatted similar to days:hh:mm:ss.sss. I have come up with an extension to MaskFormatter, inspired by http://weblogs.java.net/blog/hansmuller/archive/2005/08/using_swings_jf.html, which seems to do the job. However, a problem arises after initially inputting an elapsed time. After the initial edit, the value cannot be edited. What am I doing wrong? Here is the code with a main that illustrates the problem:

Any ideas?
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
Well, I don't know anything about how the formatters work but I replaced your custom methods with:

and the returned class is a String, not a Double so I would guess that is the difference.
jQuery in Action, 2nd edition
subject: Custom MaskFormatter
Similar Threads
Jtable double with 2 decimal and data validation
Updating GUI properties
Question about my for loop
Working with Jtable
parse date string