我有这个代码需要根据数字运行。我觉得这很容易,是的,但是这个砖墙打击了我......
我如何知道我点击哪个表或将项目放入哪个表?
private void createTablesForBuilding() {
int buildingcoutns = 3;
for (int i = 0; i < buildingcoutns; i++) {
JTable jt = new JTable();
tables.add(jt);
tables.get(i).setModel(new javax.swing.table.DefaultTableModel(
new Object[][]{
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String[]{
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
tables.get(i).getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (jt.getSelectedRow() > -1) {
System.out.print("what now???");
}
}
});
JScrollPane js = new JScrollPane();
js.setViewportView(tables.get(i));
JPanel jp = new JPanel();
jp.add(js);
Buildings_Panel.add(jp);
}
}
答案 0 :(得分:0)
{{1}}
这是myTables
{{1}}
}