Java 如何在树状视图中显示我的图标而不是箭头?
我尝试用我的图标替换TreeView中的默认箭头图标。问题是我的图标被裁剪了,尽管它只有9x9像素。要替换图标,请按照stackoverflow上的建议使用CSS:Java 如何在树状视图中显示我的图标而不是箭头?,java,css,treeview,javafx,Java,Css,Treeview,Javafx,我尝试用我的图标替换TreeView中的默认箭头图标。问题是我的图标被裁剪了,尽管它只有9x9像素。要替换图标,请按照stackoverflow上的建议使用CSS: .tree-cell > .tree-disclosure-node > .arrow { -fx-background-color: null; -fx-background-image: url("plus-icon.gif"); } .tree-cell:expanded &g
.tree-cell > .tree-disclosure-node > .arrow {
-fx-background-color: null;
-fx-background-image: url("plus-icon.gif");
}
.tree-cell:expanded > .tree-disclosure-node > .arrow {
-fx-background-color: null;
-fx-background-image: url("minus-icon.gif");
}
但这会使我的小图标被裁剪(剪切):
我试图通过使用css和填充来改变这一点,但没有任何帮助
谢谢大家! 使用9*9图标和给定的CSS:
.tree-cell .tree-disclosure-node .arrow {
-fx-shape: null;
-fx-background-color: null;
-fx-background-image: url("plus-icon.gif");
}
.tree-cell:expanded .tree-disclosure-node .arrow {
-fx-shape: null;
-fx-background-color: null;
-fx-background-image: url("minus-icon.gif");
}
您需要
-fx-
吗?它应该不仅仅是背景图像:url(“减号icon.gif”)谢谢你,皮特!这是javafx和css选择器非常相似,但前缀为-fx-。