Java – can date changes be detected on the JCalendar jdatechooser field?

I want to detect when to change the date in the jdate chooser field so that I can update another field

Is that possible? If so, where should I start? I've reviewed the documentation, but unfortunately I didn't add methods like actionlistener or statechangelistener (my first idea)

Solution

com. toedter. calendar. JCalendar inherits a listener list from JComponent, which implements Java beans. Propertychangelistener. I'll add an audience and see what happens

Editor: I think you can use addpropertychangelister () like JCalendar

JDateChooser chooser = new JDateChooser();
chooser.getDateEditor().addPropertychangelistener(
    new Propertychangelistener() {
        @Override
        public void propertyChange(PropertyChangeEvent e) {
            if ("date".equals(e.getPropertyName())) {
                System.out.println(e.getPropertyName()
                    + ": " + (Date) e.getNewValue());
            }
        }
    });
this.add(chooser);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>