Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 598965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:26:48+00:00 2026-05-13T16:26:48+00:00

After much frustration with getting a JFormattedTextField to work with my custom formats, I

  • 0

After much frustration with getting a JFormattedTextField to work with my custom formats, I was wondering if there was a Formatter or FormatterFactory that uses regular expressions?

My idea is that if there is one, then I could wrap it in a static class and invoke it like so:

mFormattedTextField.setFormatterFactory(
    SomeStaticClass.getRegexFormatFactory("^(\\d{1,}h)(\\s([0-5])?[0-9]m)?$"));

See my previous question for more background:
" I want to use a JFormattedTextField to allow the user to input time duration values into a form. Sample valid values are: 2h 30m 72h 15m 6h 0h"

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:26:48+00:00Added an answer on May 13, 2026 at 4:26 pm

    Have you read this article? In case that link rots away, it says all you really need to do override AbstractFormatter’s stringToValue method, like this:

    public Object stringToValue(String text) throws ParseException {
        Pattern pattern = getPattern();
    
        if (pattern != null) {
            Matcher matcher = pattern.matcher(text);
    
            if (matcher.matches()) {
                return super.stringToValue(text);
            }
            throw new ParseException("Pattern did not match", 0);
        }
        return text;
    }
    

    Actually, a quick search yields several fully-implemented, free solutions; were none of those sufficient to your needs?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It appears after much searching that there seems to be a common problem when
Currently trying at add ajax to a site, after much reading I discovered that
Well after much messing about I have finally got a query that gives sales
After much reading on ruby on rails and multiple database connections, it seems that
After much googling I have been wondering what the benefits/differences are between mysql and
After much looking, I found a bit of code that converts a BufferedImage to
After much struggle with getting Facebook to yield it's RSS feed for a page,
After much reading, I realized that Zend_Form can be divided into various representations, it
RESOLVED After much confusion and frustration, I finally got my hard disk to interrupt.
after much debugging, I have determined that this code is ignoring the fast enumeration

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.