DefaultTableModel model = new DefaultTableModel()
{
/**
* Override to return the data class.
*/
public Class getColumnClass(int c)
{
return getValueAt(0, c).getClass();
}
};
table.setModel(model);
If getColumnClass() is not overridden, then the returned class is Object. In this case, JTable invokes the toString() method of the Object and displayed it as a JLabel.
No comments:
Post a Comment