问题描述
我将如何添加一个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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!