0
我正在使用此代碼將JCombobox
添加到JTable
,但是當我運行此代碼時,沒有將組合框添加到Jtable
只有標題顯示在Jtable
中。將JComboBox添加到JTable
Private JTable ScrollPaneTable;
public JTable getScrollPaneTable()
{
if(ScrollPaneTable == null)
{
try
{
ScrollPaneTable = new JTable();
ScrollPaneTable.setName("ScrollPaneTable");
getJScrollPane1().setColumnHeaderView(ScrollPaneTable.getTableHeader());
TableColumn sportColumn = ivjScrollPaneTable.getColumnModel().getColumn(0);
sportColumn.setCellEditor(new DefaultCellEditor(getCombo1())); //getCombo1
returns the JCombo box reference whose items are already added.
ScrollPaneTable.setBounds(0, 0, 200, 200);
}
catch(Throwable Exc)
{
handleException(Exc);
}
}
return ScrollPaneTable;
}
這裏我只添加一個組合,但是我想在其他列中使用更多的組合。