I would like to know how to launch a Jzy3D graph from GUI. Basically I have created a simple GUI that will allow my users to display a 3D graph with scattered points if they click the "3D graph" JMenuItem. However, when I do this, instead of a white window with a graph on it, a plain white windows with nothing on it pops up instead! Also, if I put the Jzy3D stuff in the main method, it runs perfectly fine. I don't want to do this tho, I want the graph only to popup only when the user clicks that JMenuItem.
Here is the relevant part of the code.
public class OpenChart {
public void launch(){
int size = 10000;
float x;
float y;
float z;
Coord3d[] points = new Coord3d[size];
for(int i=0; i<size; i++){
x = (float)Math.random() - 0.5f;
y = (float)Math.random() - 0.5f;
z = (float)Math.random() - 0.5f;
points[i] = new Coord3d(x, y, z);
}
Scatter scatter = new Scatter(points);
System.out.println("fwee: " + points.length);
Chart chart = new Chart();
chart.getAxeLayout().setMainColor(org.jzy3d.colors.Color.RED);
chart.getView().setBackgroundColor(org.jzy3d.colors.Color.WHITE);
chart.getScene().add(scatter);
ChartLauncher.openChart(chart);
}
}
The GUI JMenuItem Code:
testAll3D.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
OpenChart open = new OpenChart();
open.launch();
}
});