title: custom UI component in java swing
body: <p>I am new to java UI and I have this basic question :</p>
  
  <p>I want to create a custom class which has 3 swing components in it,and then I want to add this components to the UI.</p>
  
  <pre><code>class ListItem extends JComponent{
      /**
       * 
       */
      private static final long serialVersionUID = 1L;
      JCheckBox checkbox;
      JLabel label;
      JButton removeBtn;
  
      public ListItem(String label) {
          this.label = new JLabel();
          this.label.setText(label);
  
          this.checkbox = new JCheckBox();
  
          this.removeBtn = new JButton();
          removeBtn.setText("Remove");
      }
  }
  </code></pre>
  
  <p>And to add it to UI I am doing this :</p>
  
  <pre><code>panelContent = new JPanel(new CardLayout());
  this.add(panelContent, BorderLayout.CENTER); //some class which is added to UI
  
  ListItem mItem = new ListItem("todo item 1");
  panelContent.add(mItem);
  </code></pre>
  
  <p>but it's not working.It's not adding anything to UI.while the following code is working perfectly:</p>
  
  <pre><code>panelContent = new JPanel(new CardLayout());
  this.add(panelContent, BorderLayout.CENTER); //some class which is added to UI
  
  JLabel lab = new JLabel();
  lab.setText("label");
  panelContent.add(lab);
  </code></pre>