Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javafx 更改标题窗格的标题图像_Javafx_Javafx 8 - Fatal编程技术网

Javafx 更改标题窗格的标题图像

Javafx 更改标题窗格的标题图像,javafx,javafx-8,Javafx,Javafx 8,使用侦听器,我打算更改标题窗格的背景图像,即使我还没有实现它。启动代码时,样式表显示“向下箭头”,但展开/折叠标题窗格时,图像消失,不显示任何内容。我使用的图像与代码和样式表位于同一文件夹中。我使用的代码如下所示: titledPane.expandedProperty().addListener((obs, wasExpanded, nowExpanded) -> { if (nowExpanded) {

使用侦听器,我打算更改标题窗格的背景图像,即使我还没有实现它。启动代码时,样式表显示“向下箭头”,但展开/折叠标题窗格时,图像消失,不显示任何内容。我使用的图像与代码和样式表位于同一文件夹中。我使用的代码如下所示:

        titledPane.expandedProperty().addListener((obs, wasExpanded, nowExpanded) -> {
            if (nowExpanded) {        
                titledPane.lookup(".title").setStyle(
                     "-fx-background-image : url('DownArrow.png'); " 
                );
            } else {
                titledPane.lookup(".title").setStyle(
                    "-fx-background-image : url('LeftArrow.png'); " 
                );                
            }
        });
CSS文件:

.titled-pane > .title {
    -fx-background-image : url('DownArrow.png'); 
    -fx-background-repeat: stretch;   
    -fx-background-position: right;
}

试着在if和else语句中打印一个句子,检查它是否真的在css中变得如此重要。title{-fx background image:url('DownArrow.png');-fx background repeat:stretch;-fx background position:right;}尝试在if和else语句中打印一个句子,以检查它是否真的在css中得到了输入。标题{-fx背景图像:url('DownArrow.png');-fx背景重复:拉伸;-fx背景位置:右;}