title: JFrame/JButton Error Messages
body: <p>I am having difficulty trying to add <code>JButton</code>s to my <code>JFrame</code>.</p>
  
  <p>I have created two methods (all within the same class for now).  If I make the <code>showGUI</code> method static, then I receive errors:</p>
  
  <pre><code>//Listen for actions on buttons.
  next.addActionListener(this); (CANNOT USE THIS IN A STATIC CONTEXT)
  previous.addActionListener(this); (CANNOT USE THIS IN A STATIC CONTEXT)
  classify.addActionListener(this); (CANNOT USE THIS IN A STATIC CONTEXT)
  </code></pre>
  
  <p>and when adding the <code>JButton</code> objects to my JFrame, I receive the following errors:</p>
  
  <pre><code>add(next); (Cannot make a static reference to the non-static method add(Component) from the type Container)
  add(previous); (Cannot make a static reference to the non-static method add(Component) from the type Container)
  add(classify); (Cannot make a static reference to the non-static method add(Component) from the type Container)
  </code></pre>
  
  <p>How can I overcome this?  I have included my method below for reference:</p>
  
  <pre><code>public void showGUI(BufferedImage img){
  
      next = new JButton("Next Image");
      next.setMnemonic(KeyEvent.VK_N);
      next.setActionCommand("disable");
  
      previous = new JButton("Previous Image");
      previous.setMnemonic(KeyEvent.VK_P);
      previous.setActionCommand("disable");
  
      classify = new JButton("Classify");
      classify.setMnemonic(KeyEvent.VK_C);
      classify.setActionCommand("disable");
  
      //Listen for actions on buttons.
      next.addActionListener(this);
      previous.addActionListener(this);
      classify.addActionListener(this);
  
      add(next);
      add(previous);
      add(classify);
  
      //Display image on the screen.
      frame.setTitle("TITLE");
      RMHC newContentPane = new RMHC();
      newContentPane.setOpaque(true);
  
      frame.setContentPane(newContentPane);
      frame.getContentPane().setLayout(new FlowLayout());
      frame.getContentPane().add(new JLabel(new ImageIcon(img)));
      frame.pack();
      frame.setVisible(true);
      frame.isResizable();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
  }
  </code></pre>