2016-07-06 34 views
0

我有css文件:CSS類爲ImageView的JavaFX的

.-fx-attribute-label { 
    -fx-min-width: 50; 
    -fx-font-weight: bold; 
} 

... 

.img-view { 
    -fx-stroke-width: 2.0; 
} 

.img-view:hover { 
    -fx-stroke: #70c0e7; 
} 

.img-view:selected { 
    -fx-stroke: #26A0DA; 
} 

,我嘗試添加IMG視圖類的ImageView:

pairStream.forEach(id -> { 
     final ImageView imgView = new ImageView(id.getValue()); 
     imgView.getStyleClass().add("img-view"); 
     facesView.getChildren().add(imgView); //facesView is Hbox which contains imageViews as children 
     ... 
    }); 

我需要強調懸停和選擇時,但它不起作用。 我知道css文件被加載,因爲其他類像-fx-attribute-label的作品。爲什麼它不適用於img-view類?

回答