mercredi 24 janvier 2018

Control Selection of Checkbox Components in a jPanel (JavaFX)

I am working on a JavaFX Application project in NetBeans with several JFrames.

I have a panel (jPanelPattern) that contains some checkboxes (jCheckBoxPat1 to jCheckBoxPat18 and they are being added to the panel continuously in the application...) with icons/images as a buttongroup. I need to save the icon/image of the selected checkbox from the path which is recorded in a database to a directory when I click the save button.

The action event of the save button contains:

for(Component c : jPanelPattern.getComponents()) { // Scan All
        if (c.isSelected()) { // Get the selected checkbox
            // Save the icon/image with FileChooser...
        } else {
            // Show message dialog for no selection...
        }
    }

Missing/Error: There is no "isSelected" and "getIcon" for the component "c" to continue select and save processes.

Question: How can I define the scanned component as a checkbox?

Any other solution way?




Aucun commentaire:

Enregistrer un commentaire