简体   繁体   English

我想将jcalendarcombo添加到jtable单元格

[英]i want to add jcalendarcombo to the jtable cell

code i have used is as follows .. bt it gives classCastException when i click on jcalendarcombo present in jtable cell. 我使用的代码如下.. bt当我单击jtable单元中存在的jcalendarcombo时,它给出了classCastException。 pls help me.. thanks in adv. 请帮助我..在ADV感谢

TableColumn closedDateColumn = resultTable3.getColumnModel().getColumn(7);
            MyDateListener listener1 = new MyDateListener();
            cmbCalanderDate = new JCalendarCombo(JCalendarCombo.DISPLAY_DATE, true); //Calander Combobox for selecting date
            cmbCalanderDate.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));

            closedDateColumn.setCellEditor(new DefaultCellEditor(cmbCalanderDate));
            cmbCalanderDate.addDateListener(listener1);

You need a JDateChooserCellEditor like they show here . 你需要一个JDateChooserCellEditor像他们表现出在这里

closedDateColumn.setCellEditor(new new JDateChooserCellEditor());

Another way is to use setDefaultEditor() . 另一种方法是使用setDefaultEditor()

table.setDefaultEditor(Date.class, new JDateChooserCellEditor());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM