I want to double click on a JDateChooser to make it enabled. So I use a MouseListener :
jDateChooser1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
System.out.println("mouse clicked");
}
});
But this event doesn't get fired, nothing happend.
The date chooser is the com.toedter.calendar one :
Any suggestion ?
Solution
The JDateChooser is a Panel, and I have to listen to a mouse event from on component in the panel. JDateChooser has a getDateEditor(), witch is the textfield.
Here is the solution :
this.jDateChooser1.getDateEditor().getUiComponent().addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
if(evt.getClickCount()==2){
Component c = ((Component)evt.getSource()).getParent();
c.setEnabled(!c.isEnabled());
}
}
});