title: Creating a XYChart on button click
body: <p>The purpose of the program is to display chart on click of the button with given parameters.</p>
  <pre><code>calcButton.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  //some calculations ...
                  XYChart chart = QuickChart.getChart(&quot;Graph&quot;, &quot;X&quot;, &quot;Y&quot;, &quot;y(x)&quot;, expression.xData, expression.yData);
                  new SwingWrapper(chart).displayChart();
  
              }
          });
  </code></pre>
  <p>However displayChart uses invokeAndWait, which cannot be executed inside ActionListener which makes sense. What is the proper way to solve this issue?</p>
  <p>I am using swing with <a href="https://github.com/knowm/XChart" rel="nofollow noreferrer">XChart</a> library</p>