我为Swing开发了一个自己的javaBean.现在,我正在尝试使用PropertyChangeListener捕获更改的两个属性.
问题是我的JavaBean中的一个属性的PropertyChangeSupport工作正常,但似乎没有为其他声明的属性触发任何propertyChange.
让我给你一些我的代码摘录:
JCalendar Bean:
public class JCalendar extends JPanel {
private int startDay, endDay;
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
public int getStartDay() {
return startDay;
}
public void setStartDay(int startDay) {
int old = this.startDay;
this.startDay = startDay;
this.pcs.firePropertyChange("startDay", old, startDay);
}
public int getEndDay() {
return endDay;
}
public void setEndDay(int endDay) {
int old = this.endDay;
this.endDay = endDay;
this.pcs.firePropertyChange("endDay", old, endDay);
}
}
Run Code Online (Sandbox Code Playgroud)
当然在Bean-Class中还有一些代码,但为了保持清晰,我将其删除.我尝试在另一个类中使用PropertyChangeListener捕获这些propertyChanges,如下所示:
class markedDayListener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent arg0) { …Run Code Online (Sandbox Code Playgroud)