Hello everyone!
I've got a problem. I'm writing a simple Jabber communicator in Java for my college project. Currently I'm dealing with GUI in Swing and i have this problem. To describe i show you the conditions in which my program runs:
I've got the main frame which is loading and shows up the JDialog (setVisible(true)) which is logging in dialog. In login dialog I've got two buttons: "Log in" and "Exit", when i click "Log in" my JDialog should disappear (setVisible(false), also tried dispose()) but it won't happen this way. When i'm clicking "Log In" in my JDialog, the Dialog is hiding but then the whole JDialog is showing once again and then finally i can close dialog but clicking the button.. I dont know why this is happening. heres my code in fragments:
The one where I'm calling the JDialog constructor(in MainWindow constructor)
The JDialog code when I'm setting JButton actionclass MainWindow extends JFrame { ... private LoginDialog login; public MainWindow() { ... if(login == null) login = new LoginDialog(this); login.setVisible(true); } }
class LoginDialog extends JDialog { ... public LoginDialog() { ... button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LoginDialog.this.setVisible(false); } }); } }
The whole code is available here: https://bitbucket.org/dardam/miracle...cf5e45f6b/src/