In the return collection getStyleClass() you need to add not the style, but the name of the class described in css . Styles can be written in .setStyle( "-fx-..." ); but for inner classes like .thumb or selectors this will not work. So something like this:
scroll.getStylesheets().add( MainApplication.class.getClassLoader().getResource("/main.css").toExternalForm() ); scroll.getStyleClass().add( "myClass" ); //scroll.setId( "myId" );
main.css
.myClass .thumb { -fx-background-color:derive(black,90%); -fx-background-insets: 0, 0, 0; -fx-background-radius: 0em; } /* #myId .thumb { -fx-background-color:derive(black,90%); -fx-background-insets: 0, 0, 0; -fx-background-radius: 0em; } */
An alternative option without a css file (it seems to work, but did not check):
for ( Node n : scrool.lookupAll( ".trumb" ) ){ n.setStyle("-fx-background-color:derive(black,90%);" + "-fx-background-insets: 0, 0, 0;-fx-background-radius: 0em;" ); }