【发布时间】:2012-07-23 03:35:00
【问题描述】:
有人可以帮我解决这个问题吗?
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e){
if(e.getValueIsAdjusting()){
ListSelectionModel model = table.getSelectionModel();
int lead = model.getLeadSelectionIndex();
displayRowValues(lead);
}
}
private void displayRowValues(int rowIndex){
String country = "";
Object oCountry = table.getValueAt(rowIndex, 0);
country += oCountry.toString();
countryTxt.setText(country );
}
});
它应该在选择其中一个行中将jtable(表)中的单元格(表)中的数据发送到TextField(CountryTXT)中,但它仅在我点击行时时工作,而不是当我骑自行车带箭头时的表格钥匙。
【问题讨论】:
标签: java swing jtable listener listselectionlistener