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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:07:14+00:00 2026-06-13T23:07:14+00:00

I use JDateChooser to edit dates in my form. Short version : I need

  • 0

I use JDateChooser to edit dates in my form.

Short version: I need to distinguish between user date edit and programmatical property change on a JDateChooser.

Workaround: I’ve found a protected JDateChooser property named dateSelected which is exactly what I need (afaics there is no getter) so probably I’d have to make my own extended JDateChooser class and make a getter for this property. The problem here is that I want to have this custom version to be draggable from the Netbeans Palette and my custom JDateChooser won’t be.

Long version:
First I get a date from my database and I use the JDateChooser’s setDate() method to set the date in the GUI. I want to edit database’s date when user picks a new date with the chooser. To do that i listen for a PropertyChange event on the JDateChooser object (looking for the “date” change). After settig the new date in the database, I want to refresh the data (I get the whole record from the database) and I set the date from the database (if there was any error, it gets set back to whatever is in the database at the moment).

The problem is that when I set the date from the database, the same event is fired whe user changes date and then my “refresh” mechanism updates the JDateChooser field and I get infinite loop.

My existing (simplified) code (netbeans):

private void dataStartuChooserPropertyChange(java.beans.PropertyChangeEvent evt) {
    if ("date".equals(evt.getPropertyName())) {
        JDateChooser wybieraczDat = (JDateChooser) evt.getSource();
        updateDatabaseField(wybieraczDat.getDate());
    }
}
  • 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-13T23:07:14+00:00Added an answer on June 13, 2026 at 11:07 pm

    I will reply to myself here because I fould a crazy way of doing this (which potentially can be worthless, but is fine for my needs). I will not create a complete working example because I dont have the time. Still some1 may benefit.

    To check wether date was chosen by user or set programatically in a PropertyChangeEvent of a JDateChooser I check a JDateChooser‘s private field called dateSelected. After I do whatever is needed (modifying database) I set this field back to false because otherwise it would stay true even if date was changed programatically again. Sample (unoptimized, ugly, only to demonstrate what I did) code below.

    JDateChooser aDateChooserInstance = new JDateChooser();
    
    // Listen for property changes
    aDateChooserInstance.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            // If the 'date' property was changed...
            if ("date".equals(evt.getPropertyName())) {
                JDateChooser aDateChooser = (JDateChooser) evt.getSource();
                boolean isDateSelectedByUser = false;
                // Get the otherwise unaccessible JDateChooser's 'dateSelected' field.
                try {
                    // Get the desired field using reflection
                    Field dateSelectedField = JDateChooser.class.getDeclaredField("dateSelected");
                    // This line makes the value accesible (can be read and/or modified)
                    dateSelectedField.setAccessible(true);
                    isDateSelectedByUser = dateSelectedField.getBoolean(aDateChooser);
                } catch (Exception ignoreOrNot) {
                }
    
                // Do some important stuff depending on wether value was changed by user
                if (isDateSelectedByUser) {
                    importantStuff();
                }
    
                // Reset the value to false
                try {
                    Field dateSelectedField = JDateChooser.class.getDeclaredField("dateSelected");
                    dateSelectedField.setAccessible(true);
                    isDateSelectedByUser = dateSelectedField.setBoolean(aDateChooser, false);
                } catch (Exception ignoreOrNot) {
                }
            }
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use JCalendar 's JDateChooser in a table date column as a tablecelleditor .
Use case : User fills out a form to add a product and register
Use Case Show a photo uploaded by the user in a square box with
use the [] symbol in the name of the form field you are submitting
I've discover this JDateChooser from searching how to use Item Combobox at Java Swing.
Use Case: End-User searches for something and an ArrayCollection is returned with Result objects.
USE CASE Search Category to find places near Your address (see form screenshot: http://o7.no/KYCj6v
I am using JDateChooser from here However I can not retrieve the date in
use Rack::Session::Pool ... session[:msg]=Hello Rack EDIT: The word session doesn't seem to resolve. I
use Control::CLI; $cli = new Control::CLI('SSH'); $cli->connect(Host=>'10.10.10.10',Username=>'user',Password=>'pwd'); $cli->waitfor('>'); $cli->print('Show XXXXXXXXXXXXXXXXXXXX| grep Active'); @f=$cli->waitfor('>'); print

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.