title: How to add the Jpanel to the Frame created
body: <p>I have created a class named Frame which simply creates a frame:</p>
  
  <pre><code>package panels;
  
  public class Frame extends prog 
  {
  
      public Frame() {
  
  
          JFrame myFrame = new JFrame();  
  
          myFrame.setLayout( new FlowLayout() );
  
          myFrame.setTitle("GUI Demo - ISTE-121");
          myFrame.pack();
          myFrame.setLocation(600,300);
          myFrame.setSize(400,200);
          myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          myFrame.setVisible(true);
  
  
  
      }
  
  }
  </code></pre>
  
  <p>Then, I have added that frame to the <code>main()</code>:</p>
  
  <pre><code>package panels;
  
  public class prog {
  
      public static void main(String args[]) {
          Frame first = new Frame();
      }
  }
  </code></pre>
  
  <p><strong>I have created a class named panels and want to add this to class Frame. How should I do that</strong>?</p>
  
  <p>The subclass is as follows:</p>
  
  <pre><code>public class panels extends Frame {
  
         final JTextField items;
         final JTextField number;
         final JTextField cost;
         final JTextField amount;
  
  
      public panels()
      {
  
  
          JPanel order = new JPanel();
            order.setLayout(new GridLayout(5,5,2,2));
  
  
            order.add(new JLabel("Item no:", SwingConstants.RIGHT));
            order.add(items = new JTextField(3));
  
            order.add(new JLabel("Number of:", SwingConstants.RIGHT));
            order.add(number = new JTextField(3));
  
            order.add(new JLabel("Cost", SwingConstants.RIGHT));
            order.add(cost = new JTextField(3));
  
            order.add(new JLabel("Amount owed:", SwingConstants.RIGHT));
            order.add(amount = new JTextField(10));
            amount.setEditable(false);
  
      }
  }
  </code></pre>