title: How to display JfreeChart ( ChartPanel ) in Jpanel generated by NetBeans
body: <p>i've generated a gui using netbeans gui generator. I have two panel and in one of this i want to show a chartpanel. The code generated by netbeans is:</p>
  
  <pre><code>private void initComponents() {
  
          jPanel1 = new javax.swing.JPanel();
  
          org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
          jPanel1.setLayout(jPanel1Layout);
          jPanel1Layout.setHorizontalGroup(
              jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
              .add(0, 394, Short.MAX_VALUE)
          );
          jPanel1Layout.setVerticalGroup(
              jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
              .add(0, 294, Short.MAX_VALUE)
          );
  
          org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
          this.setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
              .add(0, 400, Short.MAX_VALUE)
              .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                  .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                      .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                      .addContainerGap()))
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
              .add(0, 300, Short.MAX_VALUE)
              .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                  .add(layout.createSequentialGroup()
                      .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                      .addContainerGap()))
          );
      }
  </code></pre>
  
  <p>What i've done to add the chartpanel to jpanel is :</p>
  
  <pre><code>TimeSeriesCollection dataset = new TimeSeriesCollection();
              for (int i = 0; i &lt; 5; i++) {
                  TimeSeries pop = new TimeSeries("try "+i, Day.class);
                  pop.add(new Day(10+i, 1+i, 2004+i), 100*(i+2));
                  pop.add(new Day(10+1*i, 1+2+i, 2004+i+1), 150*(i+2));
                  pop.add(new Day(10+2*i, 1+2*i, 2004+i+2), 150*(i+3));
                  pop.add(new Day(10+3*i, 1+2*i, 2004+i+3), 150*(i+4));
                  pop.add(new Day(10+4*i, 1+2*i, 2004+i+10), 150*(i+5));
                  dataset.addSeries(pop);
              }
              TimeSeries pop = new TimeSeries("Try asjhaihsiuahsiuahiushaiushiauhsiuhasiua"+100, Day.class);
              int i=5;
                  pop.add(new Day(1, 1+i, 2004+i), 100*(i+2));
                  pop.add(new Day(2, 1+2+i, 2004+i+1), 150*(i+2));
                  pop.add(new Day(3, 1+2*i, 2004+i+2), 150*(i+3));
                  pop.add(new Day(4, 1+2*i, 2004+i+3), 150*(i+4));
                  pop.add(new Day(5, 1+2*i, 2004+i+10), 1500*(i+5));
                  dataset.addSeries(pop);
              JFreeChart chart = ChartFactory.createTimeSeriesChart(
                      "Population of CSC408 Town",
                      "Date",
                      "Population",
                      dataset,
                      true,
                      true,
                      false);
              ChartPanel p = new ChartPanel(chart);
  
              jPanel1.add(p);
  </code></pre>
  
  <p>But chartpanel won't show inside jpanel.. what can i do? can you help me?</p>