I'm facing problem with the simulation of the button click. I have JTextField
that takes data from scanner (like in grocery stores). After that i need to push enter button, to activate function jTextField1ActionPerformed
. Is there any way to do it without producing any button actions?
Or i need tip how to jButton1.doClick() every time jTextField is changed. Please help!:)
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
AddEmployee.add(jTextField1.getText());
jLabel7.setText(AddEmployee.name);
jLabel12.setText(AddEmployee.dep);
jLabel10.setText(AddEmployee.pos);
jLabel11.setText(AddEmployee.time);
num++;
jName.append("\n"+Integer.toString(num)+". "+AddEmployee.name);
jTime.append("\n"+Integer.toString(num)+". "+AddEmployee.time);
jTextField1.setText("");
}
catch (ClassNotFoundException | SQLException | ParseException ex) {
Logger.getLogger(MainMenu.class.getName()).log(Level.SEVERE, null, ex);
}
}