简体   繁体   English

有没有办法使用javafx向画布添加按钮

[英]Is there any way to add a button to a canvas using javafx

好吧所以我想制作一个简单的游戏,所以我用画布绘制角色,现在我需要在这个画布上添加一个按钮,让角色移动,我找不到在javaFX中这样做的方法

You can put your canvas into an AnchorPane and then you can add a Button to that too which will be shown on top of the canvas then. 您可以将画布放入AnchorPane,然后您也可以添加一个Button,然后将其显示在画布顶部。 With the anchors you can place the button exactly where you want to have it. 使用锚点,您可以将按钮准确放置在您想要的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将元素添加到Canvas JavaFX - Add Element to Canvas JavaFX 有没有办法使用 Java 向 Windows 通知区域添加“按钮” - Is there any way to add a "button" to the Windows Notification Area using Java 尝试使用 JavaFX 添加按钮时出错 - Error while trying to add a button using JavaFX 除了双击按钮之外,还有其他方法可以在设计模式下使用 windowbuilder(eclipse)将 ActionListener 添加到按钮吗? - Is there any other way to add an ActionListener to a button using windowbuilder (eclipse) in design mode than to double click on the button? 仅使用FXML设置JavaFX 2按钮的样式 - 如何将图像添加到按钮? - Styling a JavaFX 2 button using FXML only - How to add an image to a button? 将按钮添加到文本字段javafx - Add button to textfield javafx 有没有办法使用JavaFx制作windows服务应用程序 - Is there any way to make windows service application using JavaFx 如何使用Javafx中的按钮在TableView中添加新行 - How can I add a new row in tableview using a button in Javafx 图层是在JavaFX canvas上合成图形的唯一方法吗? - Are layers the only way to composite graphics on JavaFX canvas? 读取JavaFX Canvas像素的最佳方法是什么? - What is the best way to read pixels of a JavaFX Canvas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM