final JXDatePicker picker = new JXDatePicker(); FocusListener l = new FocusListener() { @Override public void focusGained(FocusEvent e) { // no api on the picker, need to use the ui delegate BasicDatePickerUI pickerUI = (BasicDatePickerUI) picker.getUI(); if (!pickerUI.isPopupVisible()) { pickerUI.toggleShowPopup(); } SwingUtilities.invokeLater(new Runnable() { public void run() { // opening the popup moves the focus to ... ? // need to grab it back onto the editor picker.getEditor().requestFocusInWindow(); } }); } @Override public void focusLost(FocusEvent e) { } }; // need to register the listener on the editor picker.getEditor().addFocusListener(l); JComponent content = new JPanel(); content.add(new JButton("dummy")); content.add(picker);
date = getUI().getSelectableDate(date); } catch (PropertyVetoException e) { return;
date = getUI().getSelectableDate(date); } catch (PropertyVetoException e) { return;
date = getUI().getSelectableDate(date); } catch (PropertyVetoException e) { return;
date = getUI().getSelectableDate(date); } catch (PropertyVetoException e) { return;
date = getUI().getSelectableDate(date); } catch (PropertyVetoException e) { return;