title: The method dispose () is undefined for the type new ActionListener(){}
body: <p>I am trying to make it so that my jframe is closed once the user presses login. However, it does not let me dispose the login window. Please help me. thank you.</p>
  <pre><code>JButton btnLogin = new JButton(&quot;Login&quot;);
      btnLogin.setFont(new Font(&quot;Tahoma&quot;, Font.PLAIN, 12));
      btnLogin.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
      
               
              
              String password = txtPassword.getText();
              String username = txtUsername.getText();
              
              if (password.contains(&quot;Marvel&quot;)&amp;&amp; username.contains(&quot;KingSlayer&quot;)) {
                  txtPassword.setText(null);
                  txtUsername.setText(null);
                  
                  {
                      
                   Main_menu info = new Main_menu();
                   
                   info.setVisible(true);
                   dispose();
                   
                  }
  </code></pre>