Get the latest version in a string of some JTextField

47 Views Asked by At

I am trying to get the latest version (last typed words) in a string.

After I do that, I show an optionsPane and ask the user to confirm the string. If not the desired one, then I ask the user to reenter.

Why am I not getting anything (blank) if the user reenters in the field? Is the focusListener not updating it after the first time?

txtWhatIsYour = new JTextField();
txtWhatIsYour.setHorizontalAlignment(SwingConstants.CENTER);
txtWhatIsYour.setBackground(SystemColor.info);
txtWhatIsYour.setBounds(150, 75, 175, 25);
frame.getContentPane().add(txtWhatIsYour);
txtWhatIsYour.setColumns(10);               
txtWhatIsYour.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {}

public void focusLost(FocusEvent e) {
            firstName = txtWhatIsYour.getText();}});
0

There are 0 best solutions below