問題描述
如何將選項卡關閉圖標 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 更改為圖像圖標的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!