我希望有人能在我找到解决办法的时候给我解释一些事情,但我不明白为什么它能起作用。我想按类类型将默认呈现器设置为整个表,但在创建时不知道对象将在其中的位置。
Calendar
所以任何
日历
s将给出一个有意义的表示,而不仅仅是一个
toString()
JTable table = new JTable();
table.setDefaultRenderer(Calendar.class, new MyRenderer());
public class MyRenderer extends DefaultTableCellRenderer{
public MyRenderer() { super(); }
@Override
public void setValue(Object value){
setText(makeCalendarToDate((GregorianCalendar)value));
}
}
在我重写方法之前,这是行不通的
getColumnClass
Here
据孙先生说
Documentation
,看起来像
getColumnClass类
现在我可以用
日历
他们在第0行,这是我想要的,但是什么阻止了我这么做呢?