how to get enabled checkbox values or names or fx:id's in javafx -


i new javafx , fxml, have created fxml few checkbox's , submit button (both inside tab called "test tab").

how enabled checkbox values and/or text and/or fx:id's , while click on submit button.

below fxml.

<?xml version="1.0" encoding="utf-8"?>  <?import java.lang.*?> <?import java.util.*?> <?import javafx.collections.*?> <?import javafx.scene.control.*?> <?import javafx.scene.effect.*?> <?import javafx.scene.image.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.paint.*?> <?import javafx.scene.shape.*?> <?import javafx.scene.text.*?> <?import javafx.scene.web.*?>  <anchorpane maxheight="-infinity" maxwidth="-infinity" minheight="-infinity" minwidth="-infinity" prefheight="400.0" prefwidth="600.0" xmlns="http://javafx.com/javafx/8.0.45" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.mainviewcontroller"> <children> <tabpane fx:id="tabpane" layoutx="7.0" layouty="6.0" prefheight="389.0" prefwidth="589.0" tabclosingpolicy="unavailable"> <tabs> <tab text="test tab"> <content> <anchorpane minheight="0.0" minwidth="0.0" prefheight="180.0" prefwidth="200.0"> <children> <button fx:id="submit" layoutx="450.0" layouty="283.0" mnemonicparsing="false" onaction="#dsubmit" text="submit" /> <checkbox fx:id="dbox1" layoutx="46.0" layouty="30.0" mnemonicparsing="false" onaction="#someaction" text="first checkbox" /> <checkbox fx:id="dbox2" layoutx="46.0" layouty="65.0" mnemonicparsing="false" onaction="#someaction" text="second checkbox" /> <checkbox fx:id="dbox3" layoutx="46.0" layouty="105.0" mnemonicparsing="false" onaction="#someaction" text="third checkbox" /> <checkbox fx:id="dbox4" layoutx="46.0" layouty="140.0" mnemonicparsing="false" onaction="#someaction" text="fourth checkbox" /> <checkbox fx:id="dbox5" layoutx="46.0" layouty="178.0" mnemonicparsing="false" onaction="#someaction" text="fifth checkbox" /> <checkbox fx:id="dbox6" layoutx="46.0" layouty="218.0" mnemonicparsing="false" onaction="#someaction" text="sixth checkbox" /> </children> </anchorpane> </content> </tab> </tabs> </tabpane> </children> </anchorpane> 

not quite sure asking, in dsubmit() method can

if (dbox1.isselected()) {     // ... }  if (dbox2.isselected()) {     // ... }  

or similar.

if want list of selected check boxes like

list<checkbox> selectedboxes =      stream.of(dbox1, dbox2, dbox3, dbox4, dbox5, dbox6)     .filter(checkbox::isselected)     .collect(collectors.tolist()); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -