SplitPane中的透明分隔线 [英] Transparent Divider in SplitPane
本文介绍了SplitPane中的透明分隔线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法让分割窗格中的分隔线透明?
Is there any way to make the Divider in a split pane transparent?
我尝试过以下方法
.split-pane *.split-pane-divider {
-fx-padding: 0 1 0 1;
}
但它不起作用。
另外,如果可能的话,我宁愿从java代码中做到这一点。
Also, I would rather do it from the java code, if it's possible.
splitPane.setStyle("");
推荐答案
使用CSS:
.split-pane:horizontal > .split-pane-divider {
-fx-background-color: transparent;
}
.split-pane:vertical > .split-pane-divider {
-fx-background-color: transparent;
}
通过代码,您需要找到分隔符并将样式应用于它。由于没有API,一个简单的方法是在显示阶段后进行查找:
By code, you need to find the divider and apply the style to it. Since there's no API for that, one easy way is with a lookup, after the stage is shown:
@Override
public void start(Stage primaryStage) {
SplitPane split = new SplitPane();
...
Scene scene = new Scene(split);
primaryStage.setScene(scene);
primaryStage.show();
Node divider = split.lookup(".split-pane-divider");
if(divider!=null){
divider.setStyle("-fx-background-color: transparent;");
}
}
这篇关于SplitPane中的透明分隔线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文