FULL PRODUCT VERSION :
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) Client VM (build 25.66-b18, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
I have a scene with a text field that has a custom skin which derives from com.sun.javafx.scene.control.skin.TextFieldSkin. The -fx-skin ist set in the css.
Right before primaryStage.show() is called, the setStyle for the text field ist called in a Platform.runLater block setting the -fx-text-fill property.
when the stage is displayed and i call setStyle(null) for the text field, the text fill will be the property default, not the css default.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a new JavaFx application.
Create a class that derives from com.sun.javafx.scene.control.skin.TextFieldSkin without any modifications.
In the style sheet for the application set the -fx-skin property for the .text-field class to the derived skin created before.
Add a TextField to the scene.
Load the style sheet to the scene.
In a Platform.runLater block call setStyle("-fx-text-fill: ... at the text field.
call primaryStage.show().
call setStyle(null) at the text field.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After setStyle(null), the text fill of the fext field shoud be the value specified in css.
ACTUAL -
After setStyle(null), the text fill of the fext field is the default value of the textFill property of the TextInputControlSkin.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class StyleTest extends Application {
private HBox root = new HBox(15);
private TextField textField = new TextField("some text");
private Button button = new Button("#");
private EventHandler<ActionEvent> buttonHandler = new EventHandler<ActionEvent>() {
private boolean doStyle = true;
@Override
public void handle(ActionEvent event) {
String styleString = doStyle ? "-fx-text-fill: green;" : null;
textField.setStyle(styleString);
doStyle = !doStyle;
}
};
@Override
public void start(Stage primaryStage) throws Exception {
button.setOnAction(buttonHandler);
root.getChildren().setAll(textField, button);
primaryStage.setScene(new Scene(root));
primaryStage.getScene().getStylesheets()
.add(getClass().getResource("styleTest.css").toExternalForm());
Platform.runLater(() -> {
buttonHandler.handle(null);
});
primaryStage.show();
button.requestFocus();
}
public static class CustomTextFieldSkin extends TextFieldSkin {
public CustomTextFieldSkin(TextField textField) {
super(textField);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
//content of the css style sheet "styleText.css":
.text-field {
-fx-text-fill: red;
-fx-skin: "test.StyleTest$CustomTextFieldSkin";
}
---------- END SOURCE ----------
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) Client VM (build 25.66-b18, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
I have a scene with a text field that has a custom skin which derives from com.sun.javafx.scene.control.skin.TextFieldSkin. The -fx-skin ist set in the css.
Right before primaryStage.show() is called, the setStyle for the text field ist called in a Platform.runLater block setting the -fx-text-fill property.
when the stage is displayed and i call setStyle(null) for the text field, the text fill will be the property default, not the css default.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a new JavaFx application.
Create a class that derives from com.sun.javafx.scene.control.skin.TextFieldSkin without any modifications.
In the style sheet for the application set the -fx-skin property for the .text-field class to the derived skin created before.
Add a TextField to the scene.
Load the style sheet to the scene.
In a Platform.runLater block call setStyle("-fx-text-fill: ... at the text field.
call primaryStage.show().
call setStyle(null) at the text field.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After setStyle(null), the text fill of the fext field shoud be the value specified in css.
ACTUAL -
After setStyle(null), the text fill of the fext field is the default value of the textFill property of the TextInputControlSkin.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class StyleTest extends Application {
private HBox root = new HBox(15);
private TextField textField = new TextField("some text");
private Button button = new Button("#");
private EventHandler<ActionEvent> buttonHandler = new EventHandler<ActionEvent>() {
private boolean doStyle = true;
@Override
public void handle(ActionEvent event) {
String styleString = doStyle ? "-fx-text-fill: green;" : null;
textField.setStyle(styleString);
doStyle = !doStyle;
}
};
@Override
public void start(Stage primaryStage) throws Exception {
button.setOnAction(buttonHandler);
root.getChildren().setAll(textField, button);
primaryStage.setScene(new Scene(root));
primaryStage.getScene().getStylesheets()
.add(getClass().getResource("styleTest.css").toExternalForm());
Platform.runLater(() -> {
buttonHandler.handle(null);
});
primaryStage.show();
button.requestFocus();
}
public static class CustomTextFieldSkin extends TextFieldSkin {
public CustomTextFieldSkin(TextField textField) {
super(textField);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
//content of the css style sheet "styleText.css":
.text-field {
-fx-text-fill: red;
-fx-skin: "test.StyleTest$CustomTextFieldSkin";
}
---------- END SOURCE ----------
- relates to
-
JDK-8334883 ☂ Nodes: nullability in properties
- Open