为什么vector作的table不能显示表头!!
JTable table;
Vector title,col,row;
row=new Vector();
col=new Vector();
title=new Vector();
title.clear();
title.add("sheng");
title.add("city");
title.add("miaoshu");
while(rs.next()){
row.clear();
row.add(rs.getString(1));
row.add(rs.getString(2));
row.add(rs.getString(3));
row.clone();
col.add(row);
}
table=new JTable(col,title);
table.add(col,title);
container.add(table,BorderLayout.CENTER);
table.repaint();
运行的结果只有表体,没有表头,请大家多多指教!!!谢谢!!!
JTable table;
Vector title,col,row;
row=new Vector();
col=new Vector();
title=new Vector();
title.clear();
title.add("sheng");
title.add("city");
title.add("miaoshu");
while(rs.next()){
row.clear();
row.add(rs.getString(1));
row.add(rs.getString(2));
row.add(rs.getString(3));
row.clone();
col.add(row);
}
table=new JTable(col,title);
table.add(col,title);
container.add(table,BorderLayout.CENTER);
table.repaint();
运行的结果只有表体,没有表头,请大家多多指教!!!谢谢!!!
JScrollPane jsp = new JScrollPane();
jsp.setViewportView(table);
container.add(jsp,BorderLayout.CENTER);
请问jsp.setViewportView实现的是什么功能呀??
JScrollPane scrollpane = new JScrollPane();
scrollpane.setViewportView(myBigComponentToScroll);
Applications should not add children directly to the scrollpane.
也就是JTable必须加到JScrollPane中才能实现滚动(JList也是这样)并且显示表头