I have a program that checks prices by entering barcodes. I want the barcode field to automatically clear after reading the first barcode. It should hold entered information for only 5 seconds and clear up for the next entry.
Here is my code and am using JFrame. It's working well, but need some help on how to time the session of every entry.
private void txt_barcodeKeyReleased(java.awt.event.KeyEvent evt) {
try {
String sql = "select * from items where barcode=?" ;
pst = conn.prepareStatement(sql);
pst.setString(1, txt_barcode.getText());
rs = pst.executeQuery();
if (rs.next()) {
String add1 = rs.getString("item_des");
txt_description.setText(add1);
String add2 = rs.getString("retail1");
txt_price.setText(add2);
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex);
}
}