-
Bug
-
Resolution: Fixed
-
P4
-
8
-
Java 1.8.0ea b94
I was wanting to style non-editable fields with a slightly darker background so I went to look and see if there is a pseudo class state set for it. To my delight it looks like there is supposed to be a "readonly" state but it looks like the editable property falsely sets the state for editable fields instead of non-editable ones.
Line 294 in TextInputControl should probably read :
pseudoClassStateChanged(PSEUDO_CLASS_READONLY, !get());
instead of:
pseudoClassStateChanged(PSEUDO_CLASS_READONLY, get());
Here's a nice little test case that highlights the bug:
**************************************************************
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class FieldTest extends Application {
@Override public void start(Stage primaryStage) throws Exception {
primaryStage.centerOnScreen();
primaryStage.setHeight(200);
primaryStage.setWidth(400);
TextField field1 = new TextField();
field1.setEditable(false);
field1.setEditable(true);
field1.setText("Field is " + (field1.isEditable() ? "" : "not ") +
"editable and pseudo states are: " +field1.getPseudoClassStates());
TextField field2 = new TextField();
field2.setEditable(false);
field2.setText("Field is " + (field2.isEditable() ? "" : "not ") +
"editable and pseudo states are: " +field2.getPseudoClassStates());
primaryStage.setScene( new Scene( new VBox( 30, field1, field2 ) ) );
primaryStage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}
Line 294 in TextInputControl should probably read :
pseudoClassStateChanged(PSEUDO_CLASS_READONLY, !get());
instead of:
pseudoClassStateChanged(PSEUDO_CLASS_READONLY, get());
Here's a nice little test case that highlights the bug:
**************************************************************
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class FieldTest extends Application {
@Override public void start(Stage primaryStage) throws Exception {
primaryStage.centerOnScreen();
primaryStage.setHeight(200);
primaryStage.setWidth(400);
TextField field1 = new TextField();
field1.setEditable(false);
field1.setEditable(true);
field1.setText("Field is " + (field1.isEditable() ? "" : "not ") +
"editable and pseudo states are: " +field1.getPseudoClassStates());
TextField field2 = new TextField();
field2.setEditable(false);
field2.setText("Field is " + (field2.isEditable() ? "" : "not ") +
"editable and pseudo states are: " +field2.getPseudoClassStates());
primaryStage.setScene( new Scene( new VBox( 30, field1, field2 ) ) );
primaryStage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}