【发布时间】:2010-10-31 19:48:13
【问题描述】:
我正在尝试使用组合框编辑 JTable 中某个列的单元格的内容。因此,我只需使用 JTables 上的官方 Java 教程 (http://download.oracle.com/javase/tutorial/uiswing/components/table.html) 中的代码。 相关代码最终如下所示:
tableModel = new NetworkTableModel(columnNames,0,0);
networkTable = new JTable(tableModel);
....
TableColumn sendingColumn = networkTable.getColumnModel().getColumn(3);
JComboBox sendingBox = new JComboBox();
sendingBox.addItem("Sending");
sendingBox.addItem("Receiving");
sendingColumn.setCellEditor(new DefaultCellEditor(sendingBox));
问题是当我单击该列中的单元格时,组合框不会出现。我完全能够编辑单元格,但只能通过输入它们。为什么 ComboBox 不显示?
【问题讨论】: