-
Bug
-
Resolution: Unresolved
-
P3
-
jfx25, jfx26
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Windows 11
A DESCRIPTION OF THE PROBLEM :
See example code below. The SplitPane contains a ScrollPane, where its minWidth and maxWidth properties are bound to the content node's width (a VBox that contains some CheckBoxes). If an additional ChekBox is added to the VBox, that makes the VBoxes width larger (and therefore the min/maxWidth of the ScrollPane), but this doesn't subsequently reflect in an updated divider position.
Some findings in the code:
1. requestLayout() or (applyCss()+)layout() don't trigger a layout update / divider position update.
2. Dragging the divider is triggering a layout update / divider position update.
3. A simple mouse click within the empty white ScrollPane region triggers an update of the divider position, but only if the click happens after(!) the additional node has beed added. If a mouse click occured before the additional node has been added, a click afterwards doesn't do anything anymore. This is all likely, because of the focus change that now goes away from the previously focused checkbox.
4. Using Labels instead of CheckBoxes a different layout behavior can be observed: the ScrollPane has initially a visible width of 0, despite the VBox has an actual width of 34px (see console output). If an additional Label (or CheckBox) is added, the visible width seems afterwards to be the 34px, despite the VBox width is then again much larger (158.7px / 180.7px).
Summary: A subsequent divider position update is lagging 'one event' behind. In the example code, it seems to me, that it is only triggered because of focus changes or drag events on the divider. A manual layout update doesn't help. The different layout behavior between labels and checkboxes is irritating/inconsistent, but again, it might be, because CheckBoxes can gain an loose focus and therefore more layout passes happen, that fix the visible presentation.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After the additional node is added to the VBox (after 5 seconds), the divider position should be updated immediately.
ACTUAL -
Divider position is not updated. It happens, but only if some 'other event' is triggering a layout update.
---------- BEGIN SOURCE ----------
public class DividerUpdateIssueDemo extends Application {
@Override
public void start(Stage stage) {
final var contentVBox = new VBox(8);
contentVBox.widthProperty().addListener((o, a, b) -> System.out.println("new vBox width: " + b));
contentVBox.getChildren().addAll(
IntStream.rangeClosed(1, 6).mapToObj(i -> new CheckBox("Item " + i)).toList());
final var scrollPane = new ScrollPane(contentVBox);
scrollPane.setFitToWidth(false);
scrollPane.setStyle("-fx-background: white;");
scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
scrollPane.minWidthProperty().bind(contentVBox.widthProperty());
scrollPane.maxWidthProperty().bind(contentVBox.widthProperty());
final var splitPane = new SplitPane(new Region(), scrollPane);
splitPane.setStyle("-fx-background-color: gainsboro;");
final var scene = new Scene(splitPane, 800, 500);
stage.setScene(scene);
stage.show();
final var scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
scheduledExecutor.schedule(() -> {
Platform.runLater(() -> {
contentVBox.getChildren().add(new CheckBox("CheckBoxWithLongItemName"));
// doesn't change anything
splitPane.requestLayout();
splitPane.layout();
});
scheduledExecutor.shutdown();
}, 5, TimeUnit.SECONDS);
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
Windows 11
A DESCRIPTION OF THE PROBLEM :
See example code below. The SplitPane contains a ScrollPane, where its minWidth and maxWidth properties are bound to the content node's width (a VBox that contains some CheckBoxes). If an additional ChekBox is added to the VBox, that makes the VBoxes width larger (and therefore the min/maxWidth of the ScrollPane), but this doesn't subsequently reflect in an updated divider position.
Some findings in the code:
1. requestLayout() or (applyCss()+)layout() don't trigger a layout update / divider position update.
2. Dragging the divider is triggering a layout update / divider position update.
3. A simple mouse click within the empty white ScrollPane region triggers an update of the divider position, but only if the click happens after(!) the additional node has beed added. If a mouse click occured before the additional node has been added, a click afterwards doesn't do anything anymore. This is all likely, because of the focus change that now goes away from the previously focused checkbox.
4. Using Labels instead of CheckBoxes a different layout behavior can be observed: the ScrollPane has initially a visible width of 0, despite the VBox has an actual width of 34px (see console output). If an additional Label (or CheckBox) is added, the visible width seems afterwards to be the 34px, despite the VBox width is then again much larger (158.7px / 180.7px).
Summary: A subsequent divider position update is lagging 'one event' behind. In the example code, it seems to me, that it is only triggered because of focus changes or drag events on the divider. A manual layout update doesn't help. The different layout behavior between labels and checkboxes is irritating/inconsistent, but again, it might be, because CheckBoxes can gain an loose focus and therefore more layout passes happen, that fix the visible presentation.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After the additional node is added to the VBox (after 5 seconds), the divider position should be updated immediately.
ACTUAL -
Divider position is not updated. It happens, but only if some 'other event' is triggering a layout update.
---------- BEGIN SOURCE ----------
public class DividerUpdateIssueDemo extends Application {
@Override
public void start(Stage stage) {
final var contentVBox = new VBox(8);
contentVBox.widthProperty().addListener((o, a, b) -> System.out.println("new vBox width: " + b));
contentVBox.getChildren().addAll(
IntStream.rangeClosed(1, 6).mapToObj(i -> new CheckBox("Item " + i)).toList());
final var scrollPane = new ScrollPane(contentVBox);
scrollPane.setFitToWidth(false);
scrollPane.setStyle("-fx-background: white;");
scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
scrollPane.minWidthProperty().bind(contentVBox.widthProperty());
scrollPane.maxWidthProperty().bind(contentVBox.widthProperty());
final var splitPane = new SplitPane(new Region(), scrollPane);
splitPane.setStyle("-fx-background-color: gainsboro;");
final var scene = new Scene(splitPane, 800, 500);
stage.setScene(scene);
stage.show();
final var scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
scheduledExecutor.schedule(() -> {
Platform.runLater(() -> {
contentVBox.getChildren().add(new CheckBox("CheckBoxWithLongItemName"));
// doesn't change anything
splitPane.requestLayout();
splitPane.layout();
});
scheduledExecutor.shutdown();
}, 5, TimeUnit.SECONDS);
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8367322 SplitPane ignores divider positions when ResizableWithParent = false
-
- Open
-