Strange problem with java CardLayout in JFrame
hello i have a Jframe with a CardLayout and 3 cards.
I have an ActionListener on a button on the first card.

This code is working well:

    JButton btnLogin = new JButton("Login");
    btnLogin.addActionListener(new ActionListener() {
    	public void actionPerformed(ActionEvent arg0) {
    		CardLayout cl = (CardLayout)(cards.getLayout());
    		cl.show(cards, "wait");
        }
    }

the problem is when i add code to do the login on the server (i'm developing an xmpp client):

    JButton btnLogin = new JButton("Login");
    btnLogin.addActionListener(new ActionListener() {
    	public void actionPerformed(ActionEvent arg0) {
    		CardLayout cl = (CardLayout)(cards.getLayout());
    		cl.show(cards, "wait");
            xmppManager = new Xmpp("jabberserver", 5222);
	        try {
		        xmppManager.init();
    	    } catch (XMPPException e) {
		        e.printStackTrace();
	        }
            cl.show(cards, "userList");
        }
    }


Basically, i need to show a "please wait" card when the user press the login button, do the login, and then show another card. But in this case, the "wait" card doesn't show, it do the login (it take around 5 seconds) and it show directly the final card "userList".

What i'm missing?
Strange problem with java CardLayout in JFrame
===

hello i have a Jframe with a CardLayout and 3 cards.
I have an ActionListener on a button on the first card.

This code is working well:

    JButton btnLogin = new JButton("Login");
    btnLogin.addActionListener(new ActionListener() {
    	public void actionPerformed(ActionEvent arg0) {
    		CardLayout cl = (CardLayout)(cards.getLayout());
    		cl.show(cards, "wait");
        }
    }

the problem is when i add code to do the login on the server (i'm developing an xmpp client):

    JButton btnLogin = new JButton("Login");
    btnLogin.addActionListener(new ActionListener() {
    	public void actionPerformed(ActionEvent arg0) {
    		CardLayout cl = (CardLayout)(cards.getLayout());
    		cl.show(cards, "wait");
            xmppManager = new Xmpp("jabberserver", 5222);
	        try {
		        xmppManager.init();
    	    } catch (XMPPException e) {
		        e.printStackTrace();
	        }
            cl.show(cards, "userList");
        }
    }


Basically, i need to show a "please wait" card when the user press the login button, do the login, and then show another card. But in this case, the "wait" card doesn't show, it do the login (it take around 5 seconds) and it show directly the final card "userList".

What i'm missing?