开发者

JXDatePicker and selectAll()

I want a listener that autoselects the entry on the JXDatePickers editor cell when same gains focus.

DatePicker.getEditor().selectAll();

doesn´t work. So i tried this :

DatePicker.getEditor().addFocusListener(new FocusListener() {
        @Override
        public开发者_如何学编程 void focusGained(FocusEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {

                    DatePicker. getEditor().selectAll();
                }
             });
        }

public void focusLost(FocusEvent e) {
}
});

Any suggestions ?


Edit

just realized that you probably have stand-alone datepicker, and run your snippet: worksforme. So we'll need to dig for differences - what's your swingx/jdk version and OS?

Original

typically, the JFormattedTextField is tricky to convince being selected ;-) See

Combining JXTable with RXTable

and adapt the solution to handle JXDatePicker as well - by adding

    if (editor instanceof JXDatePicker) {
        LOG.info("got picker: " + editor);
        invokeSelectAll(((JXDatePicker) editor).getEditor());
        return;
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜