Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot manually enter null date (in the textfield) #4

Open
tdbear opened this issue Mar 18, 2014 · 1 comment
Open

Cannot manually enter null date (in the textfield) #4

tdbear opened this issue Mar 18, 2014 · 1 comment
Labels

Comments

@tdbear
Copy link
Owner

tdbear commented Mar 18, 2014

To reproduce:

  1. create a form that contains DatePicker component
  2. click the calendar button and select any date
  3. in the textfield, erase the date
  4. call commitEdit(); it returns false; does not set the internal Date variable to null
  5. call getDate(); it returns the last valid date selected in the calendar component rather than null
@tdbear
Copy link
Owner Author

tdbear commented Mar 18, 2014

public class MyDatePickerUI extends BasicDatePickerUI implements FocusListener {
static {
UIManager.put("microba.DatePickerUI", "MyDatePickerUI");
}
public static ComponentUI createUI(JComponent c) {
return new MyDatePickerUI();
}
@Override
protected void installComponents() {
super.installComponents();
field.addFocusListener(this);
}
public void focusGained(FocusEvent e) {
// No additional behavior
}
public void focusLost(FocusEvent e) {
if (((JFormattedTextField)e.getComponent()).getText().trim().equals("")) {
((JFormattedTextField)e.getComponent()).setValue(null);
}
}
}

@tdbear tdbear added the bug label Mar 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant