2011-05-05 57 views

回答

1

首先,你需要配置表中,以便爲列選擇:

table.setColumnSelectionAllowed(true); 
table.setRowSelectionAllowed(false); 

然後你需要添加一個ActionListener選擇基於所選項目的索引列的組合框:

table.setColumnSelectionInverval(...); 
0

獲取selecte的價值d項目作爲comboBox.getSelectedItem()並將其解析爲整數,然後調用以下方法:

public void getSelected(int comboBoxValue){ 
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 

    // The following column selection method works 
    // only if these properties are set 
    table.setColumnSelectionAllowed(true); 
    table.setRowSelectionAllowed(false); 

    table.setColumnSelectionInterval(comboBoxValue, comboBoxValue); 
}