我想要按钮B和D会保留在他们的位置,当A和C将会消失,而不是它会转移到中心。我怎么能把他们转移回他们的地方?如何在GridPane中移动按钮?
fifty.setOnAction(e->{
fifty.setDisable(false);
int counter = 2;
ArrayList<String> variants = new ArrayList<>(Arrays.asList("a","b","c","d"));
variants.remove(trueAnswerIndex);
String variant;
int n = 2;
while(counter>0){
variant = variants.get(randInt(0,n));
switch(variant){
case "a":
gridButtons.getChildren().remove(a);
variants.remove("a");
break;
case "b":
gridButtons.getChildren().remove(b);
variants.remove("b");
break;
case "c":
gridButtons.getChildren().remove(c);
variants.remove("c");
break;
case "d":
gridButtons.getChildren().remove(d);
variants.remove("d");
break;
}
counter--;
n--;
}
});
https://i.stack.imgur.com/pPpC4.jpg
请在您的问题中包括您的代码。 – Nash