JCalendar焦点活动 [英] JCalendar Focus Event

查看:108
本文介绍了JCalendar焦点活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表格日期列中使用 JCalendar JDateChooser作为tablecelleditor.问题在于,当单击列单元格JDateChooser时出现,但是如果失去焦点,则不会触发焦点丢失事件.如何使其失去焦点失火事件?这样做之后,有什么方法可以防止单击JCalendar按钮后出现JCalendar时,其发射焦点丢失吗?

I use JCalendar's JDateChooser in a table date column as a tablecelleditor. The problem is that when the column cell clicked JDateChooser appears but if it loses its focus it does not fire focus lost event. How to make it fire focus lost event? And after doing this is there any way to prevent its firing focus lost when JCalendar appeared after clicking the JCalendar Button?

我想做的事情是,是否有人通过从日历中选择一个日期来指定日期.stopCellEditing();否则,等到焦点丢失事件停止或cancelCellEditing();

The thing I try to do is if some one specify a date by selecting a date from the calendar stopCellEditing(); Else wait until focus lost event to stop or cancelCellEditing();

推荐答案

我在JDateChooser中发现了一个propertyChanged事件,该事件在选择日期时被触发.然后jTable1.putClientProperty("terminateEditOnFocusLost", true);使表终止对focusLost的编辑

I found a propertyChanged event in JDateChooser which is fired when a date selected. And jTable1.putClientProperty("terminateEditOnFocusLost", true); make the table terminate edit on focusLost

如果要更改使表格单元格失去焦点并终止的年份,则当日历弹出窗口关闭时:(

Edit : When calendar popup is down if you want to change the year that make table cell lose focus and terminateEditing :(

jDateChooser.addPropertyChangeListener(new PropertyChangeListener() {

    @Override
    public void propertyChange(PropertyChangeEvent evt) {
        if (evt.getPropertyName().equals("date")) {
            stopCellEditing();
        }
    }
});

Edit(已解决):不用使用jTable1.putClientProperty("terminateEditOnFocusLost", true);TableCellEditor中的JTable中添加ta FocusListenerJTable并在失去焦点时取消编辑,从而有机会检查JDateChooser's弹出窗口是否可见.但在此之前,应使用弹出式isVisible方法扩展JDateChooser.因为弹出变量是受保护的.而且单元格编辑器组件不应是可聚焦的,否则JTable也会失去焦点

Edit(Solved) : Instead of using jTable1.putClientProperty("terminateEditOnFocusLost", true); adding ta FocusListener to JTable in TableCellEditor and cancel editing when focus lost give a chance to check if the JDateChooser's popup is visible or not. But before this, JDateChooser should be extended with a popup isVisible method. Because popup variable is protected. And cell editor components should not be focusable else JTable also loses its focus

这篇关于JCalendar焦点活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆