Menu

#6 DatePicker could not work with InputVerifier

v1.0_(example)
wont-fix
nobody
None
3
2014-03-18
2006-11-25
YiBing
No

There are needs to verify the input of DatePicker in some cases, although the input of DatePicker is alwalys a valid date time. For example, there are 2 or more DatePickers in one form, and now there is need to verify whether the two date times following the relationship between them or not.

It would be great if Microba components could work with InputVerifier. :-)

Firstly, I modified the calendarPane to not to be focusable as bug 1498275 described. Then only the JFormattedTextField is focusable in DatePicker. To let the DatePicker to work with InputVerifier, I tried these:
1. Relate DatePicker to InputVerifier. Let BasicDatePickerUI implements FocusListener and add "peer.addFocusListener(this);" in BasicDatePickerUI.installListeners() and "peer.removeFocusListener(this);" in BasicDatePicker.uninstallListeners() respectly.
The FocusListener interface implementation is like this:
public void focusGained(FocusEvent e) {
}

public void focusLost(FocusEvent e) {
if (peer.getInputVerifier()!=null){
peer.getInputVerifier().shouldYieldFocus(peer);
}
}

2. Focus management of DatePicker. For only JFormattedTextField field is focusable in DatePicker, delagating DatePicker's focus management to that of JFormattedTextField is ok. I tried to add these in BasicDatePickerUI.installComponents():
field.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
}

public void focusLost(FocusEvent e) {
for (int i=0; i<peer.getFocusListeners().length;i++) {
peer.getFocusListeners()[i].focusLost(e);
}
}
});

Discussion

  • teddybear

    teddybear - 2007-01-26
    • priority: 5 --> 3
     
  • teddybear

    teddybear - 2014-03-18
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,3 @@
    -
     There are needs to verify the input of DatePicker in some cases, although the input of DatePicker is alwalys a valid date time. For example, there are 2 or more DatePickers in one form, and now there is need to verify whether the two date times following the relationship between them or not.
    
     It would be great if Microba components could work with InputVerifier. :-\)
    
    • status: open --> wont-fix
    • Group: --> v1.0_(example)
     

Log in to post a comment.

MongoDB Logo MongoDB