final JButton searchButton = new JButton("查找"); //查找按钮
searchButton.addActionListener(new ActionListener(){//添加事件
public void actionPerformed(ActionEvent e){
int x=0;
for(x=0;x<table.getRowCount();x++) {
if(model.getValueAt(x, 0)==aTextField.getText()) return ;
}
table.setRowSelectionInterval(x,x);
}
});
panel.add(searchButton);
当点击查找按钮时出错,我是想定义行号x,循环遍历,当第0列x行的值等于aTextField中输入的值时,返回,用table.setRowSelectionInterval方法选中表格的x行。请大神看看错在哪。