Reputation: 21
the thing is that i'm using in Customize Code the next code:
DachBuscar.getDateEditor().addPropertyChangeListener(new java.beans.PropertyChangeListener(){
public void propertyChange(java.beans.PropertyChangeEvent evt){
System.out.println("Hello World");
}
});
but when i do click on the JDateChooser and i select the date, it make the action 5 times and of corse that is slower because i'm using an sql consult and that method is used 5 times, i only want to make that code 1 time, and also i thing the number of times that the method execute its more and more because i try to patch this with if and a int variable increasing each time that the method execute to use it only one time but it doesn't make effect
Upvotes: -2
Views: 1330
Reputation: 11
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);
Upvotes: 1
Reputation: 897
I think your DachBuscar.getDateEditor().addPropertyChangeListener getting called multiple times,Make sure whether your method called only once.
Upvotes: 0