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;
}
}
我有但它不允许平移,即使我启用该选项。另外,即使启用该选项,它也不会显示滚动条。 –
编辑的问题包括我的代码。 –