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

TextField does not support TextInputControl styles including psuedo-class of 'readonly' and 'editable'

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7-pool
    • Fix Version/s: fx2.1
    • Component/s: javafx

      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.




        Attachments

          Activity

            People

            • Assignee:
              leifs Leif Samuelsson (Inactive)
              Reporter:
              dzwolenskjfx Daniel Zwolenski (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:
                Imported: