john
john

Reputation: 1

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. pls help me.. thanks in 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);

Upvotes: 0

Views: 408

Answers (1)

Catalina Island
Catalina Island

Reputation: 7126

You need a JDateChooserCellEditor like they show here.

closedDateColumn.setCellEditor(new new JDateChooserCellEditor());

Another way is to use setDefaultEditor().

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

Upvotes: 1

Related Questions