點擊爲我的個人項目我的編程課,並在稍後發佈我來到一個問題,我不期望遇到。當我點擊一個菜單按鈕項時,我想要在窗格中顯示一個3d形狀,我在互聯網上搜索,搜索它以50-100種不同的方式(或一個很好的粗略估計),但沒有發現任何東西。我一直百思不得其解如何顯示單擊菜單項時的3D形狀上,這裏是我的源代碼(FXML):我如何顯示一個3d形狀按鈕在javafx
<MenuButton layoutX="14.0" layoutY="92.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="72.0" text="shapes">
<items>
<MenuItem mnemonicParsing="false" onAction="#itemcircle" text="circle" />
<MenuItem mnemonicParsing="false" onAction="#itemsquare" text="square/surfice" />
<MenuItem mnemonicParsing="false" onAction="#itemcube" text="cube" />
<MenuItem mnemonicParsing="false" onAction="#itemsphere" text="sphere" />
<MenuItem mnemonicParsing="false" onAction="#itemcyllinder" text="cyllinder" />
</items>
</MenuButton>
我的其他源代碼示例(JavaFX的):
public void itemcyllinder(ActionEvent cyllinderspawn)
{
Cylinder cylinder = new Cylinder(40, 120);
cylinder.setTranslateX(500);
cylinder.setTranslateY(-25);
cylinder.setTranslateZ(600);
}
那麼我如何使用javafx/fxml顯示三維形狀/對象?
編輯:我忘了,更不用說我希望它顯示爲一個窗格中我的場景
您是否嘗試過在按鈕上添加一個點擊事件處理程序並更改點擊'Cylinder'的可見性? – Oswald
不過是生病的嘗試。 – chucklesdeclown
也許看看在「如何創建自定義」的答案中定義的[模型查看器](http://stackoverflow.com/questions/19459012/how-to-create-custom-3d-model-in-javafx-8) JavaFX 8中的3D模型?「這不完全是你要求的,但可以提供一些關於如何實現你想要的想法。 – jewelsea