gpsstudent wrote: The action listener reads in the first 1 ok but won't read in the second entry Is there a command to like refresh the actionlistener for the next entry or what? Anything would be useful
private void barcodeField_actionPerformed(ActionEvent e) { //assigns login to temporary variable for security purposes logintmp=barcodeField.getText().trim(); //resets it to blank barcodeField.setText(null); //remove //JTextField barcodeField); //changes the text in the instruction box instructionArea.setText("Now enter your password!"); //barcodeField_actionPerformed(e); passwordtmp=barcodeField.getText().trim(); if((passwordtmp.equals(password))&&(logintmp.equals(login))) instructionArea.setText("Login Successful"); else instructionArea.setText("Incorrect Username/Password!\n" + "Hit Login to try again!"); }
//changes the text in the instruction box instructionArea.setText("Now enter your password!"); //barcodeField_actionPerformed(e); passwordtmp=barcodeField.getText().trim();
When the user hits RETURN, the text field fires an action event. JPasswordField textfield = new JPasswordField("Initial Text"); textfield.setEchoChar('*'); textfield.addActionListener(actionListener);