Javafx 将 Tab X 从 url 更改为图像图标

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

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)