Description
In the CSS reference guide, 'TextField' is not defined to inherit all the properties of TextInputControl. It would seem logical that it should.
In particular the 'readonly' and 'editable' psuedo-classes are not applicable as shown by the following code:
public void start(Stage stage)
{
VBox rootNode = new VBox();
TextField normalField = new TextField("Normal field");
rootNode.getChildren().add(normalField);
TextField readOnlyField = new TextField("Read-only field");
readOnlyField.setEditable(false);
rootNode.getChildren().add(readOnlyField);
Scene scene = new Scene(rootNode, 800, 600);
scene.getStylesheets().add("styles.css");
stage.setScene(scene);
stage.show();
}
Combined with the following stylesheet:
.text-field {
-fx-text-fill: green;
}
.text-field:editable {
-fx-text-fill: blue;
}
.text-field:readonly {
-fx-text-fill: red;
}
All text fields end up with the default style (i.e. green text) and the other two styles are completely ignored.
In particular the 'readonly' and 'editable' psuedo-classes are not applicable as shown by the following code:
public void start(Stage stage)
{
VBox rootNode = new VBox();
TextField normalField = new TextField("Normal field");
rootNode.getChildren().add(normalField);
TextField readOnlyField = new TextField("Read-only field");
readOnlyField.setEditable(false);
rootNode.getChildren().add(readOnlyField);
Scene scene = new Scene(rootNode, 800, 600);
scene.getStylesheets().add("styles.css");
stage.setScene(scene);
stage.show();
}
Combined with the following stylesheet:
.text-field {
-fx-text-fill: green;
}
.text-field:editable {
-fx-text-fill: blue;
}
.text-field:readonly {
-fx-text-fill: red;
}
All text fields end up with the default style (i.e. green text) and the other two styles are completely ignored.