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