1

Using FXML with JavaFx 8.

I have few ToggleButtons in toggleGroup, defined as:

<ToggleGroup fx:id="operater" />

I want to disable OK button, when no operater is selected. Actually, I want to negate the disable expression in ok button:

<Button disable="${operater.selectedToggle.selected}" fx:id="ok" text="OK" mnemonicParsing="false" onAction="#okClick"  >

I have tried with ! and with not(), but no success.

Thanks.

esmin
  • 491
  • 7
  • 14

1 Answers1

0

You can use an expression binding:

disable="${!operater.selectedToggle.selected}"

operater is spelt operator.

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • For some reason, it doesn't work for me. Intellij shows red-highlighted error and FXML construction throws NPE. – Eng.Fouad Dec 31 '17 at 00:43
  • It is possible that Intellij doesn't correctly parse the expressions in FXML (not sure I haven't tried that), but regardless the expressions should work when the FXML is loaded in Java. Not sure why you get the NPE though. – jewelsea Dec 31 '17 at 05:54