我在应用程序中显示了表格,并且我想获得搜索按钮,该按钮将更改表格中显示的数据。
怎么做?
txSearch = new JTextField();
txSearch.setBounds(107, 11, 150, 20);
contentPane.add(txSearch);
txSearch.setColumns(10);
JButton btnSearch = new JButton("Search");
btnSearch.setBounds(261, 10, 89, 23);
contentPane.add(btnSearch);
提前致谢
答案 0 :(得分:0)
以下是代码的一部分:
class QueryTableModel extends AbstractTableModel implements TableModelListener{
while (rs.next()) {
String[] record = new String[colCount];
for (int i = 0; i < colCount; i++) {
record[i] = rs.getString(i + 1);
}
cache.addElement(record);
}
fireTableChanged(null); // notify everyone that we have a new table.
}
} catch (Exception e) {
cache = new Vector<String[]>(); // blank it out and keep going.
e.printStackTrace();
}
}
@Override
public void tableChanged(TableModelEvent e) {
// TODO Auto-generated method stub
}
}