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

CheckBox and RadioButton ignore alignment when pref size is set

XMLWordPrintable

      Run the code :

          @Override
          public void start(Stage stage) throws Exception {
              RadioButton b1 = new RadioButton("Text");
              b1.setGraphic(new Rectangle(10, 10));
              b1.setStyle("-fx-border-color: BLACK;");
              b1.setAlignment(Pos.CENTER_RIGHT);
              b1.setPrefSize(150, 60);

              CheckBox b2 = new CheckBox("Text");
              b2.setGraphic(new Rectangle(10, 10));
              b2.setStyle("-fx-border-color: BLACK;");
              b2.setAlignment(Pos.CENTER_RIGHT);
              b2.setPrefSize(150, 60);

              VBox pane = new VBox();
              pane.getChildren().addAll(b1, b2);
              pane.setMinSize(200, 200);
              pane.setAlignment(Pos.CENTER);

              stage.setScene(new Scene(pane));
              stage.show();
          }

      Command setAlignment is ignored for radioButton and CheckBox.
      (it is not ignored for other labeled controls, as I saw)

      If you change setPrefSize() on setMinSize(), then it will work.

            Unassigned Unassigned
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Imported: