[英]treeitem icon doesn't show
I'm working with treeview in javaFx, I want to put an icon to the root node, and other icon for every child. 我正在使用javaFx中的treeview,我想在根节点放置一个图标,并为每个孩子放置一个其他图标。 I was trying to put it at least to the root node, but it still shows me the arrow, I declare the node in the next way:
我试图将其至少放置到根节点上,但是它仍然显示箭头,我以另一种方式声明了该节点:
TreeItem<Object> rootNode = new TreeItem<Object>("Agentes");
rootNode.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/images/A.png"))));
I have the image "A.png" in a package called application.images 我在名为application.images的程序包中有图像“ A.png”
, and my loader class is Main.java is located in application , this is my directory: ,而我的加载程序类是Main.java位于application ,这是我的目录:
when I run the application this is the treeview that I get: 当我运行应用程序时,这是我得到的树视图:
it doesn't show me error or something like this. 它不会显示错误或类似的内容。 I must say, A.png is a image with 16x16Pixels.
我必须说,A.png是具有16x16Pixels的图像。 I don't know what I'm doing wrong, Thanks!
我不知道我在做什么错,谢谢!
I resolved it, putting setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/images/A.png"))));
我解决了它,将
setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/images/A.png"))));
into the updateItem( Object item, boolean empty )
method in the a class that extends from TreeCell 从TreeCell扩展的类中的
updateItem( Object item, boolean empty )
方法中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.