to: one_two 非常感谢大力支持,但是, 我还是不太明白是怎么控制某个字段不显示的,但这一列还是实际存在的,能详细说明一下吗?thanks
to all: thanks all! with your strong support, the problem has been solved! The summary is as following. Till now, i still don't know why "columnModel.getColumn(j).setWidth(0);" is unavailable. 1.sourceCode: for(int i = 0; i < dayNum; i++){ this.tableDailyPlan.getColumn("id"+Integer.toString(i+1)).setMaxWidth(0); this.tableDailyPlan.getColumn("id"+Integer.toString(i+1)).setMinWidth(0); this.tableDailyPlan.getColumn("id"+Integer.toString(i+1)).setPreferredWidth(0); }
字段全部在TableModel里面,然后需要显示的字段在jtable里面写出,如果不需要显示id,那么在jtable里面就不要显示出来,但实际上id还是存在的,如果需要取道这个id,你用TableModel.getvalueAt()就可以了
table.getColumnModel().getColumn(0).setPreferredWidth(0);
非常感谢大力支持,但是,
我还是不太明白是怎么控制某个字段不显示的,但这一列还是实际存在的,能详细说明一下吗?thanks
thanks all! with your strong support, the problem has been solved! The summary is as following. Till now, i still don't know why "columnModel.getColumn(j).setWidth(0);" is unavailable. 1.sourceCode:
for(int i = 0; i < dayNum; i++){
this.tableDailyPlan.getColumn("id"+Integer.toString(i+1)).setMaxWidth(0);
this.tableDailyPlan.getColumn("id"+Integer.toString(i+1)).setMinWidth(0);
this.tableDailyPlan.getColumn("id"+Integer.toString(i+1)).setPreferredWidth(0);
}