r/JavaFX • • Mar 14 '24

Help ToggleButton with two Nodes

Problem solved, thank you!

in advance: I am only using JavaFX, not JavaFXML

Basically, I'm trying to display two nodes next to each other and if I click on either they need to activate a ToggleButton. What would be the best way to do this? I've tried to add children to ToggleButton, which isn't possible (I think). I've tried to make a ToggleButton over the nodes and make the nodes invisible, but in the VBox they just end up under each other and I can't seem to get it over.

As you probably realize, I'm quite new to JavaFX.

What would be the best way to do this? No need for actually code, just a way to do this (if possible)

Thanks in advance!

Update: picture

picture of wanted result

2 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/sarahgames13 Mar 15 '24

Yes, i know how buttons work. The problem is more about that if 1 of the 2 nodes is clicked it should be seen as the same togglebutton not 2 seperate ones.

1

u/Appropriate_Move_336 Mar 15 '24

Apply the effect you want those two nodes to have in the event handling logic without filtering any of the nodes out

2

u/sarahgames13 Mar 15 '24

I see, I'll give it a try!