mercredi 22 mai 2019

How can I perform a certain action if and only if a specific CheckBox is checked, from a separate class, at runtime?

I'm writing a program that takes a JsonFile as input and parses/sorts it before printing the result. The result is an array of JsonObjects, each JsonObject with its list of KEY_NAME's and their strings.

I also have a GUI from javafx, and a GridPane of CheckBox's, with an individual CheckBox for each KEY_NAME. What I want to do is, at runtime if a CheckBox is checked, print the JsonString corresponding to that checkbox. Essentially filtering the output of the sorted file. I want to do this from a separate class aside from the main class that put's together the javafx GUI.

Do I need to create several listener functions? Or is there a simpler way? I have 50 or so checboxes so this would be a lot of lines.

On a side note, is there a way to dynamically create these at runtime, naming them after their respective JsonString, rather than typing each CheckBox?




Aucun commentaire:

Enregistrer un commentaire