View of the application javafx

点点圈 提交于 2019-11-29 16:47:48

What I think you are asking for is a Scene with a map (represented as an Image) in the background and controls layered on top of the map to allow interaction with the map at certain positions. Your question is a little unclear, so I'm not exactly sure if that is what you are asking.

If so, here is some sample code to implement that.

For the example use the mouse (or probably touch commands or trackpad scroll gestures - though I haven't a touch screen or trackpad to test it) to drag the map around. Click on the button to "Kill the evil witch".

The solution works by:

  1. Creating an ImageView to hold the background map.
  2. Constructing the scene contents in a StackPane over the stacked background ImageView.
  3. Wrapping the scene in a ScrollPane bound to the scene's size.
  4. Setting properties on the ScrollPane to make it pannable.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!