title: how to open a new window and close the current window when I click the button on java GUI?
body: <pre><code>    if (arg0.getSource() == logOut) {       //Coding Part of log out button
          JOptionPane.showMessageDialog(this, "Logout Successful");
          new MainMenus().setVisible(false);
          LoginMenu.loginmn();
  
      }
  </code></pre>
  
  <p>this is part of my java code</p>
  
  <p>so in this part, I want to make a code that when the user clicks on the "logOut" button the program will open a new window and close the last window.</p>