Could be the same as this bug here which was a regression in 8u102: https://bugs.openjdk.java.net/browse/JDK-8183100
A workaround is to call Node#impl_reapplyCSS on the parent *after* putting the child back in the scene. But this isn't public API and is removed in Java 9, so you can alternatively just add and remove a dummy style class i.e. field.getStyleClass().add("blah") field.getStyleClass().remove("blah") which may still work in 9. Cheers, Rob -----Original Message----- From: openjfx-dev [mailto:openjfx-dev-boun...@openjdk.java.net] On Behalf Of a...@adamish.com Sent: Dienstag, 1. August 2017 16:09 To: openjfx-dev@openjdk.java.net Subject: CSS style class rendering bug (https://stackoverflow.com/questions/45440102/javafx-css-class-not-removed-when-node-disconnected) I appeared to have discovered a case in JavaFX (8u144, running on Windows 7) where a TextField is rendered using the wrong style class. This only appears to happen in the following situation * style class removed whilst Node not attached to Scene AND * parent `GridPane` has a style-class assigned, even if that class doesn't have content. I've separated the issue from a larger application into the following contrived example: public class RenderBug extends Application { private static final String ERROR = "error"; public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { TextField field = new TextField(); GridPane grid = new GridPane(); grid.getStyleClass().add("some-random-class"); grid.add(field, 0, 0); StackPane stack = new StackPane(grid); Scene scene = new Scene(stack); scene.getStylesheets().add("/foo.css"); primaryStage.setWidth(300); primaryStage.setHeight(300); primaryStage.setScene(scene); primaryStage.show(); Timeline line = new Timeline(); line.getKeyFrames().add(new KeyFrame(Duration.seconds(4), event -> { field.getStyleClass().add(ERROR); })); line.getKeyFrames().add(new KeyFrame(Duration.seconds(5), event -> { stack.getChildren().remove(grid); })); line.getKeyFrames().add(new KeyFrame(Duration.seconds(6), event -> { field.getStyleClass().remove(ERROR); })); line.getKeyFrames().add(new KeyFrame(Duration.seconds(7), event -> { stack.getChildren().add(grid); System.out.println(field.getStyleClass()); })); line.play(); } } foo.css .text-field.error { -fx-background-color: red; } .some-random-class { /** no content required */ } Screenshot. At this point TextField is red, even though the class "error" has been removed. Even interacting with the field, resizing window etc. does not fix the issue. [![TextField shown with red][1]][1] Is this a genuine bug? or am I doing something wrong? I can't find any documentation to hint that style-classes cannot or shouldn't be updated "offline" [1]: https://i.stack.imgur.com/ZPEYi.png