title: How to send an ActionPerformed from an ActionListener to another ActionListener?
body: <p>I've got a Frame (named here "MainApplication"), which mainly has a JPanel to show informations, depending on the context.</p>
  
  <p>On startup, the MainApplication has an empty JPanel.</p>
  
  <p>It then creates a "LoginRequest" class, which creates a simple login/password form, and send it back to the MainApplication, which displays it in its JPanel.</p>
  
  <p>The "LoginRequest" class implements ActionListener, so when the user clicks on the "Login" button, it checks wheter or not the login/password is correct, and, if the user is granted, I want to unload that form, and display the main screen on the MainApplication Frame.</p>
  
  <p>So, to do it, I came up with this :</p>
  
  <pre><code>public class LoginRequest implements ActionListener {
  
      protected MainApplication owner_m = null;
  
      public LoginRequest(MainApplication owner_p) {
              owner_m = owner_p;
      }
  
      @Override
      public void actionPerformed(ActionEvent event_p) {
  
          // the user just clicked the "Login" button
          if (event_p.getActionCommand().equals("RequestLogin")) {
  
              // check if login/password are correct
              if (getParameters().isUserGranted(login_l, password_l)) {
  
                  // send an ActionEvent to the "MainApplication", so as it will
                  // be notified to display the next screen
                  this.owner_m.actionPerformed(
                      new java.awt.event.ActionEvent(this, 0, "ShowSummary")
                  );
              } else {
                  messageLabel_m.setForeground(Color.RED);
                  messageLabel_m.setText("Incorrect user or password");
              }
          }
      }
  }
  </code></pre>
  
  <p>Then, the "MainApplication" class (which extends JFrame) :</p>
  
  <pre><code>public class MainApplication extends JFrame implements ActionListener {
  
      protected void load() {
              // create the panel to display information
              mainPanel_m = new JPanel();
              // on startup, populate the panel with a login/password form
              mainPanel_m.add(new LoginRequest(this).getLoginForm());
  
              this.add(mainPanel_m);
      }
  
      @Override
      public void actionPerformed(ActionEvent event_p) {
          // show summary on request
          if (event_p.getActionCommand().equals("ShowSummary")) {
  
              // remove the previous information on the panel
              // (which displayed the login form on this example)
              mainPanel_m.removeAll();
  
              // and populate the panel with other informations, from another class
              mainPanel_m.add(...);
              ...
              ...
          }
  
          // and then refresh GUI
          this.validate();
          this.repaint();
          this.pack();
      }
  }
  </code></pre>
  
  <p>When the ActionEvent is sent from the "LoginRequest" class to the "MainApplication" class, it executes the code, but at the end, nothing happens, as if the JFrame wasn't repainted.</p>
  
  <p>Any ideas ?</p>
  
  <p>Thanks,</p>