Skip to main content

jxdatepicker problem on intial loss of focus

No replies
irun5k
Offline
Joined: 2011-10-07
Points: 0

Using the test case below:

1. Change the month value

2. tab out of the field

3. note that the time precision is lost when focus is lost. Subseqent attempts will not exhibit this problem. The problem is, of course, that the user doesn't want to have to repeat their actions.

Any suggestions? Thanks in advance!

public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JPanel panel = new JPanel();
JXDatePicker p = new JXDatePicker();
p.setFormats(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"));
Date d = new Date();
p.setDate(d);
p.getEditor().setValue(d);
panel.add(p);
panel.add(new JButton("tab to me"));
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
}