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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:04:10+00:00 2026-05-17T18:04:10+00:00

this one has been puzzling me for a few days now and I feel

  • 0

this one has been puzzling me for a few days now and I feel that I have barely been able to narrow it down.

I am using Java and have a wizard for the user to step through. One of the steps allows the user to select a start time & date and an end time & date to schedule some work. I thought I had the validation on the dates complete (so that the end date must be after the start date & start date must be after current date etc). However, my validation method only fired once focus was lost on either date TextField so if the user selected a new date and immediately clicked next, an invalid choice could continue — bug!

The start and end date selectors are widgets which are made up of a JSpinner and a calendar dialog which pops up if button is clicked. I have attached a Document Listener to the text field of the JSpinner:

DocumentListener docListener = new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            dateChanged();

            System.out.println("insertUpdate");

        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            dateChanged();
            System.out.println("removeUpdate");
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            dateChanged();
            System.out.println("changedUpdate");
        }

    };
    ((JSpinner.DefaultEditor) jSpinner1.getEditor()).getTextField().getDocument().addDocumentListener(
            docListener);

When I run this class using its own main method to test:

public static void main(String[] args) {

    DateSelectorWidget test = new DateSelectorWidget();
    JFrame f = new JFrame("T E S T ");
    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(test, BorderLayout.CENTER);
    f.pack();
    f.setVisible(true);

}

The DocListener fires each time and everything is fine. However this class is part of a bigger program and when it is called in it – the DocListener simply does not fire at all. An instance of the class is simply added to a panel in the wizard and yet it does not function the way it does when tested independently.

Any ideas anyone?

Thanks

  • 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-17T18:04:10+00:00Added an answer on May 17, 2026 at 6:04 pm

    My guess is that you directly or indirectly change the editor on the JSpinner after your line to retrieve, cast, get component, get model and add listener.

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

Sidebar

Related Questions

This one has been driving me nuts for a few days now and I've
This one has been puzzling my for some time now. Let's imagine a class
This one has been driving me nuts. I have a div that has it's
Been using git for a few months now and this one has me stumped.
This one has been haunting me for quite a while now.. I have been
This one has been bugging me for a while now. Is there a way
I can see this question (or a similar one) has been asked a few
The following problem has been puzzling me for a couple of days (nb: this
This one has been confusing me and a few co-workers, but we've verified this
This one has been bugging me for a while now, but I never seem

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.