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 8522689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:11:44+00:00 2026-06-11T07:11:44+00:00

Does the Swing API have classes which combine InputVerifiers? For example, I have three

  • 0

Does the Swing API have classes which combine InputVerifiers? For example, I have three InputVerifiers in my current project:

  1. NotEmptyInputVerifier – verifies that a textfield is not empty
  2. PositiveIntegerInputVerifier – verifies that a text field contains a positive integer
  3. YearInputVerifier – verifies that a text field contains a four digit year

NotEmptyInputVerifier needs to be used for all input, whether Strings or numerical. PositiveIntegerInput needs to check that the text field is not empty and additionally check that the input string only contains digits. YearInputVerifier needs to also check that the input is exactly four digits, with the leading digit non-zero.

Now each of these builds on the other. I can easily implement this with composition or inheritence. It seems like this pattern would come up quite often in Swing applications and I think a little wrapper class, say AndInputVerifier, would be useful enough to belong in the Swing API. I haven’t been able to find one, though, so I think it doesn’t exist. ;-(

If not in the Swing API, does anyone know if this exists in a third-party package?

  • 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-06-11T07:11:46+00:00Added an answer on June 11, 2026 at 7:11 am

    The javadoc does not define any sub-class for InputVerifier, so it does not exist as such in a JVM.

    Now, it is really not complex to achieve what you want:

    import javax.swing.InputVerifier;
    import javax.swing.JComponent;
    
    public class CombinedInputVerifier extends InputVerifier {
    
        private InputVerifier[] verifiers;
    
        public CombinedInputVerifier(InputVerifier... verifiers) {
            this.verifiers = verifiers;
        }
    
        @Override
        public boolean verify(JComponent input) {
            for (InputVerifier verifier : verifiers) {
                if (!verifier.verify(input)) {
                    return false;
                }
            }
            return true;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my swing application I have a combo box with an ItemListener that does
Does the text in Swing components have a default font? In particular, what about
I have written some Java classes that do something useful. I'd like to wrap
Java Swing JTable has a getSelectedRow() method, but does not have a setSelectedRow() method.
I have a Swing app, that I start using JNLP. When I start using
A java program that does frequent swing/awt painting animation (but nothing more advanced than
Does java's swing print() have to be called on the EDT (event dispatch thread)?
In Swing JPanel said to be opaque, what does that mean? Also how JPanel
I have some classes that already use DOM4J to read XML files and provide
Does anybody know a good example of a large/complex applet based on Swing? I

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.