我尝试用我的图标替换 TreeView 中的默认箭头图标。问题是我的图标被裁剪了,尽管它只有 9x9 像素。为了替换图标,我按照 stackoverflow 上的建议使用 CSS:
.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 和 padding 来改变这一点,但它没有帮助。
谢谢!
最佳答案
使用 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");
}
关于java - 如何在 TreeView 中显示我的图标而不是箭头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19250004/