我想知道是否可以在按下某个 RadioButton 时找到索引,或者在 RadioButton 时传递 myBuns.get(i)。使用下面的代码创建 RadioButtons
RadioButton rButton;
for (i = 0; i < myBuns.size(); i ++){
rButton = new RadioButton("" + myBuns.get(i));
rButton.setToggleGroup(bunGroup);
rButton.setOnAction(this);
this.getChildren().add(rButton);
}
Run Code Online (Sandbox Code Playgroud)
感谢您的任何帮助或建议!