小编Sim*_*oon的帖子

ScrollPane删除节点时跳转到顶部

我有一个ScrollPane包含TilePane显示图像的 a 。每当我删除其中一张图像时,它ScrollPane就会跳回顶部,这在尝试删除多个图像时非常烦人。有没有办法控制滚动行为?

我在 Windows 7 上运行此代码:

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.TilePane;
import javafx.stage.Stage;

public class ScrollbarProblem extends Application{
    private TilePane imagePane;
    private ScrollPane scroller;

    @Override
    public void start(Stage primaryStage) {
        imagePane = new TilePane();
        scroller = new ScrollPane();
        scroller.setContent(imagePane);
        BorderPane root = new BorderPane(scroller, null, null, null, null);
        Scene scene = new Scene(root, 800, 600);
        primaryStage.setScene(scene);
        primaryStage.show();

        for(int …
Run Code Online (Sandbox Code Playgroud)

java javafx scrollbar javafx-8

3
推荐指数
1
解决办法
1166
查看次数

标签 统计

java ×1

javafx ×1

javafx-8 ×1

scrollbar ×1