Javafx 2 JavaFX滚动窗格,显示视口外的对象
在我当前的应用程序中,我创建了一个滚动窗格,其中包含一个锚烷作为内容。根据用户的动作,这个主播台将被我使用画布(在图像上绘制更多信息所必需)的或多或少的图像填充 但是,当我滚动滚动滚动窗格时,所有子图像仍在重新绘制,即使它们不在视口中。还有其他人有这个问题或解决方案吗 截图: 滚动窗格的初始化:Javafx 2 JavaFX滚动窗格,显示视口外的对象,javafx-2,viewport,scrollpane,Javafx 2,Viewport,Scrollpane,在我当前的应用程序中,我创建了一个滚动窗格,其中包含一个锚烷作为内容。根据用户的动作,这个主播台将被我使用画布(在图像上绘制更多信息所必需)的或多或少的图像填充 但是,当我滚动滚动滚动窗格时,所有子图像仍在重新绘制,即使它们不在视口中。还有其他人有这个问题或解决方案吗 截图: 滚动窗格的初始化: iconPane = new AnchorPane(); iconPane.setStyle("-fx-background-color: white; -fx-border-color: gray;
iconPane = new AnchorPane();
iconPane.setStyle("-fx-background-color: white; -fx-border-color: gray;");
iconPane.setMinHeight(546);
iconPane.setMinWidth(814);
scrollpane = new ScrollPane();
scrollpane.setContent(iconPane);
scrollpane.setVisible(false);
AnchorPane.setTopAnchor(scrollpane, 13.0);
AnchorPane.setBottomAnchor(scrollpane, 13.0);
AnchorPane.setLeftAnchor(scrollpane, 13.0);
AnchorPane.setRightAnchor(scrollpane, 13.0);
创建图标:
private VBox createIconPane(TaskInformation tinfo) {
VBox vbox = new VBox();
Canvas canvas = new Canvas(75, 75);
GraphicsContext gc = canvas.getGraphicsContext2D();
Image im;
if (tinfo.getCurrent() != null) {
if (tinfo.isCurrentStop()) {
String status = utilities.getCurrentTaskVersion(tinfo.getTask()).getStatus();
if (status.equals("finished")) {
im = new Image(this.getClass().getClassLoader().getResourceAsStream("dna-current.png"));
} else if (status.equals("failed")) {
im = new Image(this.getClass().getClassLoader().getResourceAsStream("dna-failed.png"));
} else {
im = new Image(this.getClass().getClassLoader().getResourceAsStream("dna-processing.png"));
}
} else {
im = new Image(this.getClass().getClassLoader().getResourceAsStream("dna-current.png"));
}
} else {
im = new Image(this.getClass().getClassLoader().getResourceAsStream("dna-excluded.png"));
}
gc.drawImage(im, 5, 5);
gc.setStroke(Color.GREEN);
gc.strokeText(tinfo.getFinished() + "", 59, 15);
gc.setStroke(Color.RED);
gc.strokeText(tinfo.getFailed() + "", 59, 28);
gc.setStroke(Color.BLUE);
gc.strokeText(tinfo.getProcessing() + "", 59, 41);
Label namelabel = new Label(tinfo.getTask().getName());
namelabel.setLayoutX(0);
namelabel.setLayoutY(68);
vbox.getChildren().addAll(canvas,
return vbox;
}
将所有图标添加到视图中:
private void createChildIcon(TaskInformation tinfo) {
VBox taskicon = createIconPane(tinfo);
taskicon.setLayoutX((tinfo.getTask().getLevel() - 6) / 2 * 120 + 5);
if (tinfo.getTask().getLevel() <= levelLastAddedTask && maxYCoor != 5) {
maxYCoor += 95;
}
levelLastAddedTask = tinfo.getTask().getLevel();
taskicon.setLayoutY(maxYCoor);
iconPane.getChildren().add(taskicon);
for (int count = 0; count < tinfo.getChildren().size(); count++) {
createChildIcon(tinfo.getChildren().get(count));
}
}
private void createChildIcon(任务信息tinfo){
VBox taskicon=createIconPane(tinfo);
taskicon.setLayoutX((tinfo.getTask().getLevel()-6)/2*120+5);
如果(tinfo.getTask().getLevel()尝试添加VM选项“-Dprism.order=j2d”。这是一种变通方法,而不是解决方案,因为它将用软件管道替换硬件加速图形管道。如果可行,请添加VM选项“-Dprism.verbose=true”,这样我们就可以看到硬件有问题
我在JavaFX问题跟踪器中添加了一个错误:。可能是一个错误。但我从未见过这样的错误。你能提供下一个信息吗:JDK版本、JFX版本(版本、构建,如果你知道的话)以及你能提供一个测试用例吗?-一段代码,我可以在其中尝试并查看问题。谢谢。