title: Adding a JPanel to a JFrame in Netbeans
body: <p>I created <code>JFrame</code> class in Netbeans and using generator I have add <code>jPanel</code>. I have also class, which extends <code>JPanel</code>. Now i want to create object of this class, and add him on the place where is my Panel in <code>JFrame</code>, but I can't find the right way, because all what I'm trying give no results</p>
  <pre><code>public static void main(String args[]) {
      
      java.awt.EventQueue.invokeLater(new Runnable() {
  
          public void run() {
              Frame f  = new Frame();
              jPanel1  = new MyPanel();
              f.pack();
              f.setVisible(true);
          }
      });
  </code></pre>
  <p>Ok, so maybe I will show more precise example what am I talking about:</p>
  <h2>first File:</h2>
  <pre><code>class MyPanel extends javax.swing.JPanel {
  public MyPanel() {
          initComponents();
          
      }
  }
  </code></pre>
  <p>Another file, with Frame:</p>
  <pre><code>public class Frame extends javax.swing.JFrame {
  public Frame() {
          initComponents();
  }
  public static void main(String args[]) {
          
          java.awt.EventQueue.invokeLater(new Runnable() {
  
              public void run() {
                  Frame f  = new Frame();
                  MyPanel p = new MyPanel();
                  jPanel1 = p;
              }
          });
      }
  private javax.swing.JButton jButton1;
  private javax.swing.JPanel jPanel1;
  </code></pre>
  <p>And I want to set on the place of jPanel1 - object MyPanel</p>