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

Label: setLabelFor() does not work dynamically

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Labels:
    • Environment:

      Win 7, 8b61

      Description

      Sample to reproduce:

      import javafx.application.Application;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.control.RadioButton;
      import javafx.scene.control.ToggleGroup;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class Main extends Application {

          public static void main(String[] args) {
              Application.launch(args);
          }

          VBox root = new VBox();

          @Override
          public void start(final Stage stage) throws Exception {
              Scene scene = new Scene(root, 300, 300);
              final Label label = new Label("_Label");
              label.setMnemonicParsing(true);
              final Button button1 = new Button("Button1");
              final Button button2 = new Button("Button2");
              ToggleGroup group = new ToggleGroup();
              RadioButton rb1 = new RadioButton("setLabelFor(button1)");
              rb1.setToggleGroup(group);
              rb1.selectedProperty().addListener(new ChangeListener<Boolean>() {
                  public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                      if (t1) {
                          label.setLabelFor(button1);
                      }
                  }
              });
              RadioButton rb2 = new RadioButton("setLabelFor(button2)");
              rb2.setToggleGroup(group);
              rb2.selectedProperty().addListener(new ChangeListener<Boolean>() {
                  public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                      if (t1) {
                          label.setLabelFor(button2);
                      }
                  }
              });
              root.getChildren().addAll(label, button1, button2, rb1, rb2);
              stage.setScene(scene);
              stage.show();
          }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                miflemi Mick Fleming (Inactive)
                Reporter:
                ogb Oleg Barbashov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved:
                  Imported: