Button 背景图像Javafx组合框

Button 背景图像Javafx组合框,button,javafx,combobox,background,Button,Javafx,Combobox,Background,有没有办法为组合框设置图像(如按钮的setGraphic()) file = new File(IMG_DIR + "load.png"); BackgroundImage bg = new BackgroundImage(new Image(file.toURI().toString()),BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, Backgrou

有没有办法为组合框设置图像(如按钮的setGraphic())

file = new File(IMG_DIR + "load.png");
BackgroundImage bg = new BackgroundImage(new Image(file.toURI().toString()),BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
            BackgroundSize.DEFAULT);
comboBox.setBackground(new Background(bg));
这是我尝试过的,但它只会产生一个黑色的背景。 作为比较,我对按钮的操作:

File file = new File(IMG_DIR + "save.png");
ImageView imageView = new ImageView(new Image(file.toURI().toString()));
buttonSave.setGraphic(imageView);
它目前的样子:

我想在组合框上放置一个加载图像,就像按钮上的图像一样。可能吗


谢谢

看起来你想在物品上画上图案。。。不是组合框。我不确定这是否是你想要实现的,但也许在这个问题中结合问题和答案是有效的。@fabian我已经发现了,但我认为可能有更简单的方法。。。