Javafx将Tab X更改为url中的图像图标 [英] Javafx change Tab X to image icon from url

查看:239
本文介绍了Javafx将Tab X更改为url中的图像图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将标签关闭图标X更改为javafx中的图像?我尝试过setGraphic(),但它只需要一个节点......我想要设置的图像是 http://eclipse-icons.i24.cc/ovr16/progress_rem.gif

How could I change the Tabs close icon X to an image in javafx? I have tried setGraphic(), but it only takes a node... the image i want to set it to is http://eclipse-icons.i24.cc/ovr16/progress_rem.gif

推荐答案

使用ImageView使图像成为有效节点,但这似乎是图标。

Make the image a valid node using ImageView, but that seems to be for icons.

Tab tab = new Tab();
Image image = new Image("http://eclipse-icons.i24.cc/ovr16/progress_rem.gif");
ImageView iv = new ImageView(image);
tab.setGraphic(iv);    

摆脱CSS中的默认形状或编写自己的形状或使用背景图像

Get rid of the default shape in CSS or write your own or use a background image

.tab-close-button {
-fx-background-color: transparent;//-fx-mark-color;
-fx-shape:null;
-fx-background-image: url("/progress_rem.gif");
}

您必须提供没有css形状的自己的点击处理程序,或者点击的东西。

You'll have to provide your own click handler without the css shape, or something to click on.

这是你用css得到的。

This is what you get with css.

这篇关于Javafx将Tab X更改为url中的图像图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆