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

查看:30
本文介绍了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天全站免登陆