I'm currently developing a login form for a chat program and want the program to load the frame and wait for the userinput. Unforunately the program opens the frame, but at the same time resumes the main method. I hope you have some ideas to help me.
Greetings
public static void main(String[] args){
boolean running = true;
//Starting JFrame
chatFrame.loginFrame();
//Processing - Receiving Status from Login method
if(getStatus() == 1){
...
} else {
System.out.println("An Error occured..");
System.exit(0);
}
}
JFrame Class:
public class chatFrame{
private static String sLogin;
private static String password;
public static void loginFrame(){
System.out.println("Launching Frame");
JFrame loginFrame = new JFrame();
loginFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextField user = new JTextField("Username");
JTextField pass = new JTextField("Password");
JButton login = new JButton("Login");
loginFrame.setLayout(new BorderLayout());
loginFrame.add(user, BorderLayout.NORTH);
loginFrame.add(pass, BorderLayout.CENTER);
loginFrame.add(login, BorderLayout.SOUTH);
loginFrame.pack();
loginFrame.setSize(250, 150);
loginFrame.setVisible(true);
login.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.out.println("Action performed");
String sLogin = user.getText();
String password = pass.getText();
//Calling Login method
ClEngine.login(sLogin, password);
System.out.println("dataIn:" + dataIn);
loginFrame.setVisible(false);
}
});
}
}