I am having trouble with an if-Statement in Javafx, where i check the id of the selected Radiobutton, and if it matches the string, i want to set the price of something
for (int i = 0; i < 3; i++) {
String rbFor = "rb" + i;
if (rbFor == ((Node) tg.getSelectedToggle()).getId()) {
preis = sizePrice[i];
}
}
now the problem with this is, that it just doesn't work. i can set also a regular string for example rb0 and it won't do the if statement.
rb stands for RadioButton and I set their id to "rb"+i , where i is from 0-2.
tg is my ToggleGroup for these RadioButtons.
My guess is, that it's somehow connected to the node-cast, but i am unable to solve this on my own.
I also tried something like this
if (((RadioButton) scene.lookup("#rb" + i)).isSelected())
and similar casts. but that always gave me an error.
also doing something like this didn't work:
String rbSet = ((Node) tg.getSelectedToggle()).getId();
if (rbFor == rbSet)
Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire