Javafx change Tab X to image icon from url(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 更改为图像图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Javafx 将 Tab X 从 url 更改为图像图标


- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01