1
我想知道如何从GUI启动Jzy3D图形。基本上我创建了一个简单的图形用户界面,如果用户单击“三维图形”JMenuItem,将允许我的用户显示具有分散点的三维图形。然而,当我这样做时,而不是一个带有图形的白色窗口,而是一个没有任何东西的普通白色窗口弹出来!另外,如果我把Jzy3D的东西放在主要方法中,它运行得很好。我不想这样做,我只希望图形只在用户单击该JMenuItem时才弹出。如何从GUI启动Jzy3d图形?
这里是代码的相关部分。
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);
}
}
的GUI的JMenuItem代码:
testAll3D.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
OpenChart open = new OpenChart();
open.launch();
}
});
是否尝试启动ETD的外侧图表? – MadProgrammer 2012-07-21 03:09:37
我很抱歉,ETD是什么意思? – 2012-07-21 17:37:01
由事件派发线程(etd)分派的所有swing事件。这也是处理绘画请求的责任。没有使用jzy3d,我们可能会阻止彼此(这可能会解释为什么它在单独运行时会起作用)。你尝试在另一个线程中启动图表 – MadProgrammer 2012-07-21 20:14:39