I am trying to create a simple login system and i want the user to be able to proceed to the next part when they hit the enter button, and ive managed to get it working on the registration part, so that when the user has finished putting in their details they can hit enter and the program goes to the next part but i want it so that when the user is entering their login details they can hit enter and then the program will execute the next part of the code.
card3 = new JPanel();
usernameFieldone = new JTextField(10);
usernameLabel = new JLabel("Username:");
usernameLabel.setLabelFor(usernameFieldone);
passwordFieldone = new JPasswordField(10);
passwordLabel = new JLabel("Password:");
passwordLabel.setLabelFor(passwordFieldone);
passwordFieldre = new JPasswordField(10);
passwordLabelre = new JLabel("Confirm Password: ");
passwordLabelre.setLabelFor(passwordFieldre);
passwordFieldre.addKeyListener(this);
OKButton = new JButton("OK");
OKButton.addActionListener(this);
backButton = new JButton("Back");
backButton.addActionListener(this);
public void keyReleased(KeyEvent e){
CardLayout cl = (CardLayout)(cards.getLayout());
if(e.getKeyCode()==KeyEvent.VK_ENTER){
if(
Register();
}
}`