添加的ActionListener来jCalendar [英] Adding actionListener to jCalendar

查看:94
本文介绍了添加的ActionListener来jCalendar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何添加一个ActionListener到现有jCalendar的jDayChooser组件使用NetBeans放在哪里?

How would I add an actionListener to the jDayChooser component of an existing jCalendar placed using netbeans?

我想只会引发的点击一天按钮只有当一个事件。在jCalendar的为propertyChange监听连jMonthChooser和jYearChooser

I would like to only trigger an event only when the day buttons are clicked. as the propertyChange in jCalendar listens to even the jMonthChooser and jYearChooser

P.S。使用toedter的jCalendar

P.S. using toedter's jCalendar

推荐答案

另外,你可以听FO具体 propertyName的

Alternatively, you can listen fo the specific propertyName, "day".

JDayChooser jdc = new JDayChooser();
jdc.addPropertyChangeListener("day", new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent e) {
        System.out.println(e.getPropertyName()+ ": " + e.getNewValue());
    }
});

附录:?如何得到它的工作 JCalendar

同样, propertyName的日历重新presents一个日历从中可以的get() DAY_OF_MONTH

Similarly, the propertyName, "calendar" represents a Calendar from which you can get() the DAY_OF_MONTH.

JCalendar jc = new JCalendar();
jc.addPropertyChangeListener("calendar", new PropertyChangeListener() {

    @Override
    public void propertyChange(PropertyChangeEvent e) {
        final Calendar c = (Calendar) e.getNewValue();   
        System.out.println(c.get(Calendar.DAY_OF_MONTH));   
    }
});

这篇关于添加的ActionListener来jCalendar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆