Hi All! I have a table that there is a combo box inside the table. For example, the combo box consist of item codes. And then, whenever user choose item from combo box, the next column inside the table will show name of the item. Here is my example coding:
sql = "SELECT desc_bar FROM inv_item WHERE kode_bar = '" + cboBarang.getSelectedItem().toString() + "'";
stmt = Koneksi.getConnection().createStatement();
rs = stmt.executeQuery(sql);
if (rs.last()){
tabel.setValueAt(rs.getString(1), 0, 1);
} else {
tabel.setValueAt("", 0, 1);
}
My question is how if there is many rows in a table. I tried to use this, tabel.setValueAt(rs.getString(1), tabel.getSelectedRow(), 1).
But it showed me an error, which is: index out of bound. So, how to do this ( I hope you'll understand what I'm trying to do here because my english isn't good enough :$)? Can you help me? Thx before. :)