title: Adding a WindowListener to JFrame (Window Opened)
body: <p>This is my view class. The main class actually launches the program. The below code was used in the view lass since it contains the GUI and event handlers (action listeners).</p>
  
  <pre><code>public class TheaterView extends JFrame implements WindowListener{
      public void windowOpened(WindowEvent e) {
              displayMessage("WindowListener method called: windowOpened.");
      }
  }
  </code></pre>
  
  <p>This is what I'm doing but it gives the error message: TheaterView is not abstract and does not override abstract method windowDeactivated(WindowEvent) in WindowListener.</p>
  
  <p>Anyway, I implement the methods and get this (I get others too, but this is the only one I need):</p>
  
  <pre><code>@Override
      public void windowOpened(WindowEvent e) {
          throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
      }
  </code></pre>
  
  <p>However, it doesn't seem to work when I do anything like use the println command. I want it to do something once the program runs for the first time i.e. when the windows is opened.</p>
  
  <p>I searched a lot but I couldn't figure it out yet. Any help would be appreciated :)</p>
  
  <p>Code in main:</p>
  
  <pre><code>TheaterView theater = new TheaterView("Movie Theater");
  theater.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  theater.setLocation(200, 200);
  theater.pack();
  theater.setVisible(true);
  </code></pre>