gpt4 book ai didi

JavaFX 图形故障

转载 作者:行者123 更新时间:2023-11-30 08:01:52 24 4
gpt4 key购买 nike

我的应用程序遇到奇怪的图形故障。情况是我正在创建一些 GridPane 并将它们添加到 ScrollPane 内的父 GridPane 中。然而,在滚动时,一些奇怪的故障开始发生。这是一张图片:(抱歉必须使用链接,我没有足够的声誉来发布图像)。

http://s11.postimg.org/x9eg8bz4z/Glitch.png

这是它应该是什么样子的图片:

http://s11.postimg.org/cqjk39l7n/Normal.png

这是我的代码:

private static class Controller implements Initializable {

@FXML private GridPane projectsPane;

@Override
public void initialize(URL location, ResourceBundle resources) {
//I first create some objects to be used when
//creating the GridPanes in the following loop,
//but I have removed the code for simplicity
for(AvailableProject availableProject : availableProjects) {
GridPane projectPane = new GridPane();
projectPane.setBackground(new Background(new BackgroundFill(Color.DARKGREY, CornerRadii.EMPTY, Insets.EMPTY)));
ColumnConstraints column1 = new ColumnConstraints();
column1.setPercentWidth(50);
ColumnConstraints column2 = new ColumnConstraints();
column2.setPercentWidth(50);
projectPane.getColumnConstraints().addAll(column1, column2);
projectPane.setPadding(new Insets(5));
Label projectName = new Label(availableProject.projectName);
GridPane.setValignment(projectName, VPos.CENTER);
projectPane.add(projectName, 0, 0);
TextFlow description = new TextFlow(new Text(availableProject.description));
description.setMaxSize(200, 100);
GridPane.setValignment(description, VPos.CENTER);
projectPane.add(description, 0, 1);
Label category = new Label(availableProject.category);
GridPane.setValignment(category, VPos.CENTER);
GridPane.setHalignment(category, HPos.RIGHT);
projectPane.add(category, 1, 0, 1, 2);
projectsPane.add(projectPane, 0, yRow);
yRow++;
Pane pane = new Pane();
pane.setMinHeight(15);
projectsPane.addRow(yRow, pane);
yRow++;
}
}
}

我尝试简化代码以使其更清晰,但如果需要,我将发布其余部分。

谢谢!

最佳答案

我似乎找到了解决办法。从表面上看,这确实是一个错误。我稍后会向 Oracle 报告。问题似乎是我的 ScrollPane 中有填充。根据我的测试,如果 padding 大于 5,就会出现故障。解决方法是将填充分配给父 GridPane 而不是 ScrollPane。

关于JavaFX 图形故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31797219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com