Login Screen Before APP Start

Hi, i have an login screen that pops up before the jME app starts. When the user fills his personal information and click "submit" the app simply doesn't starts :/.



Here is some piece of code(I have removed the imports and removed the initSimpleGame TODO-code):


public class Main extends SimpleGame implements ActionListener {

    JFrame frame = new JFrame("Login");

    JTextField userText = new JTextField();
    JPasswordField passText = new JPasswordField();
    String userT;
    String passT;

    public static void main(String[] args) {
        Main myGUI = new Main();
        myGUI.createAndShowGUI();
    }

    public void createAndShowGUI() {
        JFrame.setDefaultLookAndFeelDecorated(true);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(new Dimension(200, 250));
        frame.setLayout(null);

        JLabel userLabel = new JLabel("Digite seu usu

You are creating two Main instances, which means you create two SimpleGame instances.

This can't be good.

Try to create a separate class for your JFrame which then creates only one SimpleGame instance.



Also try using the debugger to see where your Game hangs.

I made this:


public class Main extends SimpleGame {

    public static void main(String[] args) {
        myFrame loginFrame = new myFrame();
        loginFrame.createAndShowGUI();
    }

    public void initTheGame() {
        Main app = new Main();
        app.setConfigShowMode(ConfigShowMode.AlwaysShow, Main.class.getClassLoader()
             .getResource("splash.png"));
        app.start();
    }

    @Override
    protected void simpleInitGame() {
        
    }
}

class myFrame implements ActionListener {

    JFrame frame = new JFrame("Login");

    JTextField userText = new JTextField();
    JPasswordField passText = new JPasswordField();
    String userT;
    String passT;

    public void actionPerformed(ActionEvent e) {
        checkUserInfo();
    }

        public void createAndShowGUI() {
        JFrame.setDefaultLookAndFeelDecorated(true);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(new Dimension(200, 250));
        frame.setLayout(null);

        JLabel userLabel = new JLabel("Digite seu usu

It seems to be something in setConfigShowMode, as it works when you comment that out.

You're still creating two Main-classes though and the getText() method of JPasswordField is deprecated, use new String(passText.getPassword()) instead.