I am trying to get a user email to verify that it is the user. Before this I run a series of test to see if the user does need to input the email. I am struggling to create create the frame once and wait for the user to input their email into the required field.
What happens is the window is not generated and eats up all available processing power. I have tried wait() / notify()
and timers but neither are doing what I need.
Is there a better way to (within a if / else
block) to generate a window and wait for a user input before doing anything else?
public class Security extends JFrame{
//Code stuff here to see if this is needed
String email = "";
boolean windowCreation = true;
do{
do{
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Security frame = new Security();
frame.setVisible(true);
windowCreation = false;
} catch (Exception e) {
e.printStackTrace();
}
}
});
}while(windowCreation);
} while(!email.equals(""));
//More code stuff here to use "email" the way I need to
}
Here is the just of what the window is doing
Security()
{
getContentPane().setLayout(null);
textField = new JTextField();
textField.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent key) {
if(key.getKeyCode() == KeyEvent.VK_ENTER)
{
Security.email = field.getText();
}
}
});
textField.setBounds(10, 115, 415, 20);
getContentPane().add(textField);
textField.setColumns(10);
}