JavaFX - ToggleButton basics

271 Views Asked by At

I have two ToggleButton objects that are inside the same GridPane.

ToggleButton a = new ToggleButton("A");
ToggleButton b = new ToggleButton("B");
grid.addRow(1, a, b,);

If I press a, b un-presses. I cannot press a to un-press a. I would like each button to act independently of the other. Meaning pressing a does nothing to b, and if a was previously pressed, it would then un-press.

I tried doing

a.setToggleGroup(null)

but this does not change anything.

How can this be done? Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

Actually, the functionality is working. It's just that the JavaFX focus color is obscuring the pressed coloration of the button. I changed the colors in css to make the pressed more obvious to the user.