title: Button click in Applet opens another Applet Java
body: <p>How can I use <code>ActionListener</code> to open another applet in my eclipse package by pressing a button?</p>
  
  <p>is it setVisible(true) or something else. I already did this; </p>
  
  <pre><code>report.addActionListener(this);
  </code></pre>
  
  <p>and implemented it but what do I put in the method? </p>
  
  <pre><code>public void actionPerformed(ActionEvent arg0) {
  }
  </code></pre>
  
  <p>Here's the context if you want:</p>
  
  <pre><code>import java.applet.*;
  import java.awt.*;
  import java.awt.event.*;
  import java.net.URL;
  
  public class Test extends Applet implements ActionListener {
  
  Image img;
  Image image;
  Button security = new Button("Security Controls");
  Button activity = new Button("Activity Logs");
  Button report =  new Button("Employee Report");
  Button reportc = new Button(" Company Report");
  Button loginout = new Button("Log out");
  Button bug = new Button("Report a bug");
  
  Button about = new Button("About");
  Button filejk = new Button("File");
  Button help = new Button("Help");
  
  Button inbox = new Button("Inbox");
  Button insta = new Button("Quick View");
  
  
  Button access = new Button("Employee Record");
  Button accessc = new Button("Company Sales");
  Button manager = new Button("Alert Manager");
  Button alerte = new Button("Alert Employee");
  Button reward = new Button("Reward System");
  Label answerr = new Label("Breaking News!");
  TextArea answers = new TextArea("John has acquired Reward Level 3.\n"
          + "Mary is having dinner with the CEO.\n" + "Company has increased sales by          45% this month.", 4, 30,
          TextArea.SCROLLBARS_NONE);
  
  public void init() {
      setSize(750, 600);
      Frame c = (Frame) this.getParent().getParent();
      c.setTitle("HiroshimaBlock");
      img = getImage(getDocumentBase(), "dancer2.gif");
      image = getImage(getDocumentBase(), "hsblock.png");
      add(security);
      add(activity);
      add(report);
      add(loginout);
      add(bug);
      add(about);
      add(reportc);
      add(filejk);
      add(help);
      add(access);
      add(accessc);
      add(manager);
      add(alerte);
      add(reward);
      add(inbox);
      add(insta);
      add(answerr);
      answers.setEditable(false);
      add(answers);
      report.addActionListener(this);
  
  }
  
  public void update(Graphics g) {
      g.drawImage(img, 250, 80, 260,200, this);
      g.drawImage(image, 120,10, this);
  
  
      this.security.setLocation(25, 200);
      this.security.setSize(120, 25);
      this.activity.setLocation(25, 250);
      this.activity.setSize(120,25);
      this.report.setLocation(25,300);
      this.report.setSize(120,25);
      this.loginout.setLocation(25,500);
      this.loginout.setSize(120,25);
      this.reportc.setLocation(25,350);
      this.reportc.setSize(120,25);
      this.bug.setLocation(25, 400);
      this.bug.setSize(120,25);
      this.filejk.setLocation(0,0);
      this.filejk.setSize(40,25);
      this.about.setLocation(40,0);
      this.about.setSize(40,25);
      this.help.setLocation(80,0);
      this.help.setSize(40,25);
      this.access.setLocation(595,200);
      this.access.setSize(120,25);
  
      this.accessc.setLocation(595,250);
      this.accessc.setSize(120,25);
      this.alerte.setLocation(595,300);
      this.alerte.setSize(120,25);
      this.manager.setLocation(595,350);
      this.manager.setSize(120,25);
      this.reward.setLocation(595,400);
      this.reward.setSize(120,25);
      this.inbox.setLocation(300,300);
      this.inbox.setSize(150,75); 
      this.insta.setLocation(325,390);
      this.insta.setSize(100, 50);
      this.answers.setLocation(265,525);
      this.answerr.setLocation(263, 500);
      g.setColor(Color.red);
      Graphics2D g2 = (Graphics2D)g;
      g2.setStroke(new BasicStroke(2));
      g.drawLine(0, 180, 200, 180);
      g.drawLine(200, 180, 200, 1100);
      g.drawLine(545, 180, 800,180);
      g.drawLine(545, 180, 545, 1100);
  }
  
  public void paint(Graphics g) {
  
      update(g);
  }
  
  
  @Override
  public void actionPerformed(ActionEvent arg0) {
  }
  }
  </code></pre>
  
  <p>Here's the weird error:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
  at Test.actionPerformed(Test.java:126)
  at java.awt.Button.processActionEvent(Unknown Source)
  at java.awt.Button.processEvent(Unknown Source)
  at java.awt.Component.dispatchEventImpl(Unknown Source)
  at java.awt.Component.dispatchEvent(Unknown Source)
  at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
  at java.awt.EventQueue.access$200(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue$4.run(Unknown Source)
  at java.awt.EventQueue$4.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue.dispatchEvent(Unknown Source)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.run(Unknown Source)
  </code></pre>