title: Launching another Applet from another Applet
body: <p>I have made a Loader Applet which greets the user and when user clicks the button displayed on that Applet it then launches the main applet and the Loader Applet is destroyed.</p>
  
  <p>But on clicking Another applet is not launched !</p>
  
  <p><strong>Loader Applet:</strong> </p>
  
  <pre><code>import java.awt.Button;
  import java.awt.FlowLayout;
  import java.awt.Graphics;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.JApplet;
  
  public class Loader extends JApplet implements ActionListener{
      Display secondApplet;
      Button button;
  
      @Override
      public void init() {
          setSize(800,600);
      }
  
      @Override
      public void start() {
          setLayout(new FlowLayout());
          button = new Button ("Click me !!");
          add(button);
          button.addActionListener(this);
      }
  
      @Override
      public void paint(Graphics g) {
  
      }
  
      @Override
      public void actionPerformed(ActionEvent e) {
          secondApplet = (Display)getAppletContext().getApplet("Display");
          if (secondApplet != null) {
              secondApplet.init();
              secondApplet.start();
          }
          else {
              System.out.println("Not Running\n");
          }
      }
  }
  </code></pre>
  
  <p><strong>Display Applet:</strong></p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Graphics;
  import javax.swing.JApplet;
  
  public class Display extends JApplet {
  
      @Override
      public void init() {
          setSize(600,400);
      }
  
      @Override
      public void paint(Graphics g) {
          g.fillRect(0, 0, this.getWidth(), this.getHeight());
      }
  }
  </code></pre>
  
  <p><strong>How can I create an instance of the other Applet and destroy the current Applet !!</strong></p>