title: How to add a custom component to JFrame?
body: <p>I'm experiencing issues with adding a new object (of my custom class <code>TemplatesList</code>) to a <code>JFrame</code>. I added a <code>Picture</code> object to the JFrame before and that works perfect. But when I want to add an object of my own class, it returns an error for some reason.
  Can you please help me with identifying the problem? I would appriciate. </p>
  
  <p>The error says: <code>cannot resolved method add(lista)</code> when I try to add this:</p>
  
  <pre><code> TemplatesList lista = new TemplatesList();
   frame.add(lista);
  </code></pre>
  
  <p>here's the code:</p>
  
  <pre><code>    import javax.swing.*;
      import java.awt.Color;
      import java.awt.FlowLayout;
      import javax.swing.JList;
  
      public class ChoosingPage
      {
      static JFrame frame;
      JLabel choose;
  
      public ChoosingPage ()
      {
          frame = new JFrame ("Primark's templates");
          frame.setSize(500,500);
          frame.setLocation(50,50);
          frame.setLayout(new FlowLayout(FlowLayout.CENTER));
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          //frame.setBackground(Color.WHITE);
          frame.getContentPane().setBackground(Color.WHITE);
  
          choose = new JLabel("choose your template");
          choose.setSize(choose.getPreferredSize());
          //choose.setLocation(20,20);
          frame.add(choose);
  
          Picture zdjecie = new Picture();
          frame.add(zdjecie);
  
          TemplatesList lista = new TemplatesList();
          frame.add(lista);
  
  
  
  
          frame.setVisible(true);
      }
  
      public static void main (String [] args)
      {
          new ChoosingPage();
      }
      }
  </code></pre>
  
  <p>and the class which I want to add to the JFrame:</p>
  
  <pre><code>import javax.swing.*;
  
  public class TemplatesList
  {
      private JComboBox faceCombo;
  
      public TemplatesList()
      {
          faceCombo = new JComboBox();
          faceCombo.setEditable(false);
          faceCombo.addItem("change request");
          faceCombo.addItem("Emergancy Change request");
          faceCombo.addItem("problem request");
          faceCombo.addItem("problem handover");
  
      }
  }
  </code></pre>