1
如何使用scrollPane在全屏應用程序中顯示大於屏幕的圖像?我有一個大約爲8000x3800像素的圖像,我希望能夠移動整個圖像並與其進行交互,而無需調整大小。如果你希望關於我的代碼的細節,或者一般問問。如何使用scrollPane顯示大於屏幕的圖像JavaFX
public class SourceCodeVersion8 extends Application{
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
AnchorPane mapAnchorO = addMapAnchor();
Scene mapScene = new Scene(mapAnchorO);
primaryStage.setScene(mapScene);
primaryStage.setFullScreen(true);
primaryStage.setResizable(false);
primaryStage.show();
}
//Creates an AnchorPane for the map
private AnchorPane addMapAnchor()
{
AnchorPane mapAnchor = new AnchorPane();
ScrollPane mapScrollO = addMapScroll();
mapAnchor.getChildren().add(mapScrollO);
AnchorPane.setLeftAnchor(mapScrollO, 0.0);
AnchorPane.setTopAnchor(mapScrollO, 0.0);
return mapAnchor;
}
//Creates an ImageView for the map
private ImageView addMapView()
{
Image mapImage = new Image("WorldProvincialMap-v1.01.png");
ImageView mapView = new ImageView(mapImage);
return mapView;
}
//Creates a scrollPane for the map
private ScrollPane addMapScroll()
{
ScrollPane mapScroll = new ScrollPane();
ImageView mapViewO = addMapView();
mapScroll.setContent(mapViewO);
mapScroll.setPannable(true);
return mapScroll;
}
}
我有但它不允許平移,即使我啓用該選項。另外,即使啓用該選項,它也不會顯示滾動條。 –
編輯的問題包括我的代碼。 –