title: How to put JFrame with jmathplot graph in JPanel
body: <p><strong>Note</strong>: this question is a follow up question from <a href="https://stackoverflow.com/questions/18315407/jmathplot-doesnt-work-in-swing-application">this question</a>.</p>
  
  <p>I have just learned the following from my last question:</p>
  
  <p><code>JPanel</code> has <code>FLowLayout</code> (with the same output as from <code>NullLayout</code>! on resize), accepting only <code>PreferredSize</code>, child aren't resizable with its container, is required to use <code>BorderLayout</code>/<code>GridLayout</code> for simple graph</p>
  
  <p>A demonstration of this principle was also given:</p>
  
  <pre><code>import java.awt.BorderLayout;
  import java.awt.Dimension;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  import javax.swing.SwingUtilities;
  import org.math.plot.Plot2DPanel;
  import java.awt.BorderLayout;
  import java.awt.Dimension;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  import javax.swing.SwingUtilities;
  import org.math.plot.Plot2DPanel;
  
  public class MyPlot {
  
      private JFrame frame = new JFrame("JMathPlot library in a swing application.");
      private JPanel panel = new JPanel();
  
      public MyPlot() {
          double[] x = new double[]{0, 1, 2, 3, 4, 5};
          double[] y = new double[]{10, 11, 12, 14, 15, 16};
          Plot2DPanel plot = new Plot2DPanel() {
              @Override
              public Dimension getPreferredSize() {
                  return new Dimension(400, 200);
              }
          };
          plot.addLinePlot("my plot", x, y); // add a line plot to the PlotPanel
          panel.setLayout(new BorderLayout());
          panel.add(plot);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.add(panel);
          frame.pack();
          frame.setLocation(150, 150);
          frame.setVisible(true);
      }
  
      public static void main(String[] args) {
  
          SwingUtilities.invokeLater(new Runnable() {
              @Override
              public void run() {
                  new MyPlot();
              }
          });
      }
  }
  </code></pre>
  
  <p>Now what I want to achieve is to integrate the graph into a <code>parent JPanel</code> to use it in my swing application.</p>
  
  <p>A visualisation of this would be:</p>
  
  <p><img src="https://i.stack.imgur.com/XKXcr.jpg" alt="enter image description here"></p>
  
  <p>How do I implement the graph in my 'parent' JPanel without violating the constraints for making it work properly?</p>
  
  <p>(I looked into <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/JInternalFrame.html" rel="nofollow noreferrer">JInternalFrame</a> but couldn't come up with a correct implementation for my problem)</p>
  
  <p>If JInternalFrame is indeed the solution, how should I use it? (Please supply code)</p>