Hi, I have a Jframe with CardLayout and 3 cards. I have an ActionListener on a button on the first map.
This code works 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 that I am adding code to enter the server (I am 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 the “Wait” card, when the user clicks the login button, log in and then display another card. But in this case, the “wait” card is not displayed, it does the login (takes about 5 seconds), and it directly displays the final card “userList”.
What am I missing?
source
share