code: public JFrame displayChartMatrix() {
  
      // Create and set up the window.
      final JFrame frame = new JFrame(windowTitle);
  
      // Schedule a job for the event-dispatching thread:
      // creating and showing this application's GUI.
      javax.swing.SwingUtilities.invokeLater(
          new Runnable() {
  
            @Override
            public void run() {
  
              frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              frame.getContentPane().setLayout(new GridLayout(numRows, numColumns));
  
              for (T chart : charts) {
                if (chart != null) {
                  XChartPanel<T> chartPanel = new XChartPanel<T>(chart);
                  chartPanels.add(chartPanel);
                  frame.add(chartPanel);
                } else {
                  JPanel chartPanel = new JPanel();
                  frame.getContentPane().add(chartPanel);
                }
              }
  
              // Display the window.
              frame.pack();
              frame.setVisible(true);
            }
          });
  
      return frame;
    }
docs: Display the chart in a Swing JFrame