I want to calculate the value returned on payment of a certain price using keyPressed event on Java .this code :
private void txtbyrKeyPressed(java.awt.event.KeyEvent evt) {
int harga = Integer.parseInt(txthrg.getText());
int byr = Integer.parseInt(txtbyr.getText());
int kembali = harga-byr;
txtkmbli.setText(String.valueOf(kembali));
}
i have wrong calculation output and error :
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""