2011-05-05 103 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); 
}