Reputation:
I have the following css class in css file
.split-pane > .split-pane-divider {
-fx-background-insets: 0;
-fx-padding: 0 0 0 0;
-fx-background-color: red;
}
And I have a splitPane with two dividers and I have reference to these dividers as Node(!). I mean
Node leftDivider;
Node rightDivider;
I get reference to them this way
List<Node> nodes=getDividerNodes(splitPane);
leftDivider=nodes.get(0);
rightDivider=nodes.get(1);
...
public static List<Node> getDividerNodes(SplitPane splitPane){
Map<Double,Node> sortedMap=new TreeMap<>();
if (splitPane.getOrientation()==Orientation.HORIZONTAL){
splitPane.lookupAll(".split-pane-divider").stream().forEach(div -> {
if (div.getParent()==splitPane){
sortedMap.put(div.getLayoutX(), div);
}
});
}else{
splitPane.lookupAll(".split-pane-divider").stream().forEach(div -> {
if (div.getParent()==splitPane){
sortedMap.put(div.getLayoutY(), div);
}
});
}
return new ArrayList<>(sortedMap.values());
}
Now I wan't to display leftDivider but not to display rightDivider. I do
leftDivider.setStyle("-fx-padding: 0 5 0 0;");
However, I see both dividers - left and right. Besides, if I want to see only right divider and I do
rightDivider.setStyle("-fx-padding: 0 5 0 0;");
I don't see any dividers.
It seems to me that separate control of dividers inside one splitPane is not possible. If I wrong, please, say how can I show only one of two dividers?
Upvotes: 3
Views: 460
Reputation: 209684
This looks like a bug. In particular, the SplitPaneSkin
class contains the following method:
private void layoutDividersAndContent(double width, double height) {
final double paddingX = snappedLeftInset();
final double paddingY = snappedTopInset();
final double dividerWidth = contentDividers.isEmpty() ? 0 : contentDividers.get(0).prefWidth(-1);
for (Content c: contentRegions) {
// System.out.println("LAYOUT " + c.getId() + " PANELS X " + c.getX() + " Y " + c.getY() + " W " + (horizontal ? c.getArea() : width) + " H " + (horizontal ? height : c.getArea()));
if (horizontal) {
c.setClipSize(c.getArea(), height);
layoutInArea(c, c.getX() + paddingX, c.getY() + paddingY, c.getArea(), height,
0/*baseline*/,HPos.CENTER, VPos.CENTER);
} else {
c.setClipSize(width, c.getArea());
layoutInArea(c, c.getX() + paddingX, c.getY() + paddingY, width, c.getArea(),
0/*baseline*/,HPos.CENTER, VPos.CENTER);
}
}
for (ContentDivider c: contentDividers) {
// System.out.println("LAYOUT DIVIDERS X " + c.getX() + " Y " + c.getY() + " W " + (horizontal ? dividerWidth : width) + " H " + (horizontal ? height : dividerWidth));
if (horizontal) {
c.resize(dividerWidth, height);
positionInArea(c, c.getX() + paddingX, c.getY() + paddingY, dividerWidth, height,
/*baseline ignored*/0, HPos.CENTER, VPos.CENTER);
} else {
c.resize(width, dividerWidth);
positionInArea(c, c.getX() + paddingX, c.getY() + paddingY, width, dividerWidth,
/*baseline ignored*/0, HPos.CENTER, VPos.CENTER);
}
}
}
As you can see, dividerWidth
is computed for a single divider, and the same value is used in the layout of all dividers. Consequently all dividers are the same size, irrespective of the different styles they may each have.
I recommend you search to see if this is already reported (I did a quick search and didn't find anything), and report it if not.
Upvotes: 0