Strangely the style does'nt change if i manually change the css class rules in one of the css document and switch between the 2 files.
@Override
public void initialize(URL url, ResourceBundle rb) {
final String cssUrl1 = getClass().getResource("/tracker/view/fxmlgui1.css").toExternalForm();
final String cssUrl2 = getClass().getResource("/tracker/view/fxmlgui2.css").toExternalForm();
rootPane.getStylesheets().add(cssUrl1);
rootPane.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent keyEvent) {
if (keyEvent.getCode().equals(KeyCode.DIGIT1)) {
rootPane.getStylesheets().clear();
rootPane.getStylesheets().add(cssUrl1);
msgLabel.setText("Css1 selected.");
} else if (keyEvent.getCode().equals(KeyCode.DIGIT2)) {
rootPane.getStylesheets().clear();
rootPane.getStylesheets().add(cssUrl2);
msgLabel.setText("Css2 selected.");
}
}
});
}
The event occurs and the style change from css1 and css2 as they was at the time of stage rendering, but if then i change one of the rules in the sylesheets after the stage is layed out, the style does'nt change anymore.
So wich is the general way to change the style of nodes changing the css document at runtime?
It's as the initial stylesheets in the css documents are someway cached and does'nt update at any switch.