Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8123626

TextInputControl pseudo class state "readonly" is being set for editable fields

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Environment:

      Java 1.8.0ea b94

      Description

      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);
         }
         
      }
       

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              csmithjfx Charles Smith (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: