Skip to content
Advertisement

How to create Radio buttons with 2-Way Exclusivity in JavaFx [closed]

I want to build something like this. From a k value and Map<String,List> I want to build a scoring system, the k value is the number of the maximum vote, the map has as keys the names of some groups of people and as values the list of people’s names.

Here we have a ugly and not working preview with k=3

JavaScript

Advertisement

Answer

I agree with what @jewelsea mentioned in the comments. Having said that, after going through the demo in the link, I thought to give a try and see how this can be achieved.

So far the trick I am using is:

  • Set toggle groups on either by rows or columns.
  • Create a two dimensional array by the opposite of what you choosed for toogle groups. I mean,
    • if you choose toggle groups by rows, then create a 2D array by columns as first dimension.
    • if you choose toggle groups by columns, then create a 2D array by rows first dimension.

Now when a radio button is selected, the toggle group will take care of one dimension toggling..and all you need is to check the other dimension radioButtons and select the correct one.

Below is the code of the logic:

enter image description here

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement