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

Text is not centered in the textfield if the text is set programatically

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: fx2.1
    • Fix Version/s: None
    • Component/s: javafx
    • Labels:
    • Environment:

      JavaFX 2.1 build b17, WindowXp

      Description

      https://forums.oracle.com/forums/message.jspa?messageID=10219772

      If you set the text in the constructor, the center of the text is in the center of the control.
      But if you set the text programmatically (and the text was previously empty), then then the left side of the text is in the center of the control.

      final TextField tf = new TextField();
      Button btn = new Button("update");
      btn.setOnAction(new EventHandler<ActionEvent>(){

      @Override
      public void handle(ActionEvent t) {
      tf.setText("Hello");
      }
      });
      tf.setAlignment(Pos.CENTER);
      tf.setMinSize(200, 24);
      tf.setMaxSize(200, 40);
      tf.setPrefSize(200, 40);
      tf.setStyle("-fx-font: 20 arial;");

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              leifs Leif Samuelsson (Inactive)
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: