title: java.lang.illegalargumentexception adding a window to a container
body: <p>I keep receiving this error</p>
  
  <pre><code>    import javax.swing.*; 
      import java.awt.*;
      import java.awt.event.*;
      import java.util.*;
      import javax.swing.table.*;
      import java.awt.Container.*;
  
       public class main extends JFrame implements ActionListener
      {
  
  
  
      JButton CustomerOrder;
      JButton SoftwareProducts;
      JButton BooksProducts;
      JButton AddBooks;
      JButton StaffMember;
      JButton LoginView;
  
  
      static ArrayList&lt;Software&gt; softwareList = new ArrayList&lt;Software&gt;();
  
      CardLayout c1 = new CardLayout();
  
  
      JPanel mainPanel;
      SoftwareProducts addsoftware;
  
      CustomerOrder customerorder;
  
      BooksProducts addProduct;
  
      AddBooks addBook;
  
      SoftwareProducts sf = new SoftwareProducts();
  
      //Press submit;
  
      public static void main(String[] args)
     {
  
      new main();
      JFrame frame = new JFrame("Selling Product");
      frame.setLocationRelativeTo(null);
      //frame.getContentPane().add(main, BorderLayout.CENTER);
      //new CustomerOrder();
      //EmailFrame email=new EmailFrame();
      //CustomerOrder co = new CustomerOrder();
      //LoginView login = new LoginView();
  
    }
  
  public main(){
  
      super();
  
  
  
  
    // getContentPane().setBackground(Color.green);
  
  
  
  
  
     setSize(700,800);
     setLayout(new FlowLayout());
  
       /*CardLayout cardLayout = (CardLayout) mainPanel.getLayout();
       cardLayout.show(mainPanel, "softwareProducts");
       */
  
  
     //CustomerOrder co = new CustomerOrder();
     //add(co);
  
  
  
     SoftwareProducts = new JButton("SoftwareProducts");
     SoftwareProducts.setSize(150,40);
     SoftwareProducts.setLocation(20,50);
  
  
     CustomerOrder = new JButton("CustomerOrder");
     CustomerOrder.setSize(160,40);
     CustomerOrder.setLocation(150,50);
  
  
  
     BooksProducts = new JButton("BooksProducts");
     BooksProducts.setSize(200,40);
     BooksProducts.setLocation(310,50);
  
  
     AddBooks = new JButton("AddBook");
     AddBooks.setSize(200,40);
     AddBooks.setLocation(310,50);
  
  
     StaffMember = new JButton("StaffMember");
     StaffMember.setSize(200,40);
     StaffMember.setLocation(310,50);
  
  
     LoginView = new JButton("LoginView");
     LoginView.setSize(150,40);
     LoginView.setLocation(20,50);
  
  
     SoftwareProducts.addActionListener(this);
  
     add(SoftwareProducts);
  
     CustomerOrder.addActionListener(this);
  
     add(CustomerOrder);
  
     BooksProducts.addActionListener(this);
  
     add(BooksProducts);
  
     AddBooks.addActionListener(this);
  
     add(AddBooks);
  
  
     StaffMember.addActionListener(this);
  
     add(StaffMember);
  
  
  
  
     mainPanel = new JPanel();
     mainPanel.setBackground(Color.BLUE);
     mainPanel.setPreferredSize(new Dimension(600,500));
     mainPanel.setLayout(c1);
  
  
  
  
  
  
  
     addsoftware = new SoftwareProducts();
     mainPanel.add(addsoftware,"addsoftware");
  
  
     customerorder = new CustomerOrder();  ////// I am getting the error
          from this part of code  
     mainPanel.add(customerorder,"customerorder");///// I am getting the     
           error from this part of code  
  
     addProduct = new BooksProducts();
     mainPanel.add(addProduct,"addProduct");
  
  
     addBook = new AddBooks();
     mainPanel.add(addBook,"addBook");
  
  
  
    /*  mainPanel.add(SoftwareProducts);
  
       mainPanel = new JPanel(new CardLayout());
  
       mainPanel.add(SoftwareProducts);
  
       getContentPane().add(mainPanel);
  
  
       addProduct = new BooksProducts();
       mainPanel.add(addProduct,"addProduct");
  
  
      */
  
  
  
  
        add(mainPanel);
  
  
  
  
  
  
         setVisible(true);
  
  }
  
  
  
  
  public void actionPerformed(ActionEvent e)
  {
  
     if(e.getSource() == SoftwareProducts)
     {
  
      c1.show(mainPanel,"addsoftware");
      this.setTitle("SoftwareProducts");
      //System.out.println("Softwares");
      }
  
  
      if(e.getSource() == CustomerOrder)
     {
  
      c1.show(mainPanel,"customerorder");
      this.setTitle("CustomerOrder");
      //System.out.println("Custmers");
      }
  
  
       if(e.getSource() == BooksProducts)
     {
  
       c1.show(mainPanel,"addProduct");
       this.setTitle("BooksProducts");
      }
  
      if(e.getSource() == AddBooks)
     {
  
       c1.show(mainPanel,"addBook");
       this.setTitle("AddBooks");
      }
  
     if(e.getSource() == LoginView)
     {
  
       c1.show(mainPanel,"LogIN");
       this.setTitle("LOGIN");
      }
  
  }
  
        /*  public void actionPerformed(ActionEvent e)
          {
        if(e.getSource() == press)
   {
  
      System.out.println("addProducts");
      }
  
     }*/
    }
  </code></pre>
  
  <p>and my customerOrder class </p>
  
  <pre><code>      import javax.swing.*;
        import javax.swing.table.*; 
        import java.awt.*;
        import java.awt.event.*;
        import java.util.Arrays; 
        import java.util.ArrayList;
        import java.util.Collections;
        import java.util.List;
        import java.util.*;
        import java.io.*;
         public class CustomerOrder extends JFrame 
       implements  ActionListener 
  
    {
  
  //JButton asd = new JButton("BUTTON");
  //JTextField productID;
  //JTextField productName;
  //JTextField productCost;
  //JTextField productPYear;
  //JTextField productPHouse;
  
  JButton showOrder;
  
  
  DefaultListModel&lt;String&gt; model = new DefaultListModel&lt;&gt;();
  JList &lt;String&gt;orderList = new JList(model);
  JTable softwareTabel = new JTable();
  
  
  //DefaultTableModel tableModel = new DefaultTableModel(0, 1);
  
  
  public CustomerOrder()
  {
  
      //super();
  
     // JLabel toLabel=new JLabel("Product ID: ");
      //JTextField to=new JTextField();
  
  
      setLayout(new FlowLayout());
  
  
     /* 
      productName = new JTextField(12);
      add(productName);
  
      productCost = new JTextField(12);
      add(productCost);
  
      productPYear = new JTextField(12);
      add(productPYear);
  
  
      productPHouse = new JTextField(12);
      add(productPHouse);
  
      */
      showOrder = new JButton("SHOW ORDER");
      showOrder.setSize(25,40);
      showOrder.addActionListener(this);
      add(showOrder); 
  
  
  
  
  
  }
  
  
  public void actionPerformed(ActionEvent e)
  
  {
      //Object[] colNames={"Product ID","Processor","RAm"};
      if(e.getSource() == showOrder)
      {  
           model.removeAllElements();
  
         /*  GridLayout exLayout = new GridLayout(3, 3);
  
           JLabel ram,processor; 
  
           ram = new JLabel("RAM");
           processor = new JLabel("Processor");
           String softwaredata[] = {"ID","RAM","Processor","Product ID","Product Name","Product Year","Product Year","Product PublishHouse"};
  
           JPanel panel = new JPanel();
           panel.setLayout(new GridLayout(8,   3));
  
           add(ram);
           add(processor);
  
           JTable table = new JTable();*/
           //DeafultTableModel dm = new DeafultTableModel(0,0);
            //String header[] = new String[] {"RAM", "Processor","ProductID","Product Name","Product Year","Product Publish House"}; 
            //dm.setColumnIdentifiers(header);
            //Object[][] software = new Object[8][3];
  
            //model.addRow(orderList.toArray());
  
  
  
            int x = 0;
         while (x &lt; main.softwareList.size())
          {
              //./model.addElement(main.softwareList.get(x).getproductYear());
               model.addElement(""+main.softwareList.get(x).getproductID());
               model.addElement(""+main.softwareList.get(x).getRam());
               model.addElement(""+ main.softwareList.get(x).getProcessor());
               model.addElement(""+ main.softwareList.get(x).getproductID()); 
               model.addElement(main.softwareList.get(x).getproductName());
               model.addElement(""+ main.softwareList.get(x).getproductYear());
               model.addElement(main.softwareList.get(x).getproductPublishHouse());
               //model.addElement(main.softwareList.get(x).getproductID());*/              
  
               x++;
  
            //System.out.println("as");
  
  
          }
            /* ArrayList&lt;String&gt; table1 = new ArrayList();
  
            ArrayList&lt;ArrayList&lt;String&gt;&gt; table2 = new ArrayList();
            table1.add("Product ID");
            table1.add("RAM");
            table1.add("Processor");
            table1.add("Product Name");
            table1.add("Product Year");
            table1.add("Product PHouse");
  
            Object[] software = table1.toArray();
            String[] [] softwarest = new String[table1.size()][];
  
            int i = 0;
            for (List&lt;String&gt; next : table2){
  
               softwarest[i++] = next.toArray(new String[next.size()]);
              }
  
  
  
              JTable newTable = new JTable(softwarest,software);
  
              JFrame frame = new JFrame();
              frame.getContentPane().add(new JScrollPane(newTable));
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              */
               //table.add(model);
  
           // add(orderList);
          //Object[] column = {"RAM:", "Processor:"};
          //Object[][] data = {{"RAM:", "Processor:"}};
          //JTable table = new JTable();
          //table.setShowGrid(false);
          //table.setTableHeader(null); 
  
      }
  
  
  
  }
  
  
  
   }
  </code></pre>
  
  <p>When i run this code i get the following exception from the main class in customerorder = new CustomerOrder;
  mainPanel.add(customerorder,"customerorder")</p>