JScrollPane jscrollPane = new JScrollPane();
for (Object date : keys) {
//每次循环 都建立一个jtable
List<HistoryMessage> hmList = (List<HistoryMessage>) sourceMap.get(date);
Object[][] rowData = new Object[hmList.size()][3];
JPanel topPanel = new JPanel();
JLabel jTopLabel = new JLabel();
jTopLabel.setText((String)date);
topPanel.add(jTopLabel);//这个panel没有显示
for (int i=0;i<hmList.size();i++) {
rowData[i][0]=sdf2.format(hm.getDate());
rowData[i][1]=hm.getName();
rowData[i][2]=hm.getContent();
}
JTable jtable = new JTable(rowData, columnNames);
//把topPanel添加到jscrollpane中
jscrollPane.add(topPanel);
//把jtable添加到jscrollpane中
jscrollPane.getViewport().add(jtable);
}
[img]http://dl.iteye.com/upload/attachment/550094/4a566c17-f8b2-3bd4-b5d9-544f33d7d5b3.png[/img]
没有标题 什么的,而且遍历只运行了一次啊,应该有好几个panel才对啊,求解答