From 17a0d9e8ca57b9166194ae9df8b70de166d9fbc6 Mon Sep 17 00:00:00 2001 From: Tim Molter <tim.molter@gmail.com> Date: Fri, 6 Sep 2013 17:16:23 +0200 Subject: [PATCH] JFrame now accessable from SwingWrapper. See Issue # 44. --- .../java/com/xeiam/xchart/SwingWrapper.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/xchart/src/main/java/com/xeiam/xchart/SwingWrapper.java b/xchart/src/main/java/com/xeiam/xchart/SwingWrapper.java index 9106bc4f..a3c9a90e 100644 --- a/xchart/src/main/java/com/xeiam/xchart/SwingWrapper.java +++ b/xchart/src/main/java/com/xeiam/xchart/SwingWrapper.java @@ -73,7 +73,10 @@ public class SwingWrapper { /** * Display the chart in a Swing JFrame */ - public void displayChart() { + public JFrame displayChart() { + + // Create and set up the window. + final JFrame frame = new JFrame("XChart"); // Schedule a job for the event-dispatching thread: // creating and showing this application's GUI. @@ -82,8 +85,6 @@ public class SwingWrapper { @Override public void run() { - // Create and set up the window. - JFrame frame = new JFrame("XChart"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel chartPanel = new XChartPanel(charts.get(0)); frame.add(chartPanel); @@ -93,12 +94,17 @@ public class SwingWrapper { frame.setVisible(true); } }); + + return frame; } /** * Display the chart in a Swing JFrame */ - public void displayChartMatrix() { + public JFrame displayChartMatrix() { + + // Create and set up the window. + final JFrame frame = new JFrame("XChart"); // Schedule a job for the event-dispatching thread: // creating and showing this application's GUI. @@ -107,8 +113,6 @@ public class SwingWrapper { @Override public void run() { - // Create and set up the window. - JFrame frame = new JFrame("XChart"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new GridLayout(numRows, numColumns)); @@ -129,6 +133,8 @@ public class SwingWrapper { frame.setVisible(true); } }); + + return frame; } } -- GitLab