Java swing中,表格不显示header 怎么办?
代码:
- parameterTable_1 = new JTable();
- parameterTable_1.setRowSelectionAllowed(false);
- // JScrollPane jscrollPane22=new JScrollPane();
- // panel_14.add(parameterTable_1.getTableHeader(),BorderLayout.NORTH);
- panel_14.add(parameterTable_1);
解决方法:把table放在JScrollPane 中
- parameterTable_1 = new JTable();
- parameterTable_1.setRowSelectionAllowed(false);
- // JScrollPane jscrollPane22=new JScrollPane();
- // panel_14.add(parameterTable_1.getTableHeader(),BorderLayout.NORTH);
- panel_14.add(new JScrollPane(parameterTable_1));
运行结果:
参考:http://hw1287789687.iteye.com/blog/2254518