Reputation: 135
I'll cut to the chase. I'm try to add Toedter's JDateChooser in a column of a JTable. My app is using MVC pattern, this is from my View:
scrollPanePermits = new JScrollPane();
tableVehiclePermitHeader = new String[] {"Name", "Expiration Date"};
tableVehiclePermitData = new Object [0][0];
tableVehiclePermitDefaultTableModel = new DefaultTableModel(tableVehiclePermitData, tableVehiclePermitHeader);
tableVehiclePermit = new JTable(tableVehiclePermitDefaultTableModel){
// public Class getColumnClass(int c) {
// return getValueAt(0, c).getClass();
// }
public Class getColumClass(int c){
if(c == 0){
return String.class;
} else if (c == 1){
return JDateChooser.class;
}
return null;
}
public boolean isCellEditable(int rowIndex, int colIndex){
if (colIndex == 0){
return false;
} else {
return true;
}
}
};
I honestly have no way to go about it, so any help would be greatly appreciated.
Regards.
Upvotes: 0
Views: 1108
Reputation: 205805
I've never tried it, but you might start with Concepts: Editors and Renderers. Here's a related example using Double
and a thread about using JDateChooser
.
Upvotes: 1