So I have a JavaFX code that creates an Accordion with TitledPanes and each TitledPane have a checkBox:
So my question is there is any way to get the value of those checkBoxes after a button click: i.e: I pick a specific checkboxes and when i click on a button it will pring me all the checkedBoxes values
and here is the code:
import java.net.MalformedURLException;
import java.util.Map;
import io.swagger.models.HttpMethod;
import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.Response;
import io.swagger.models.Swagger;
import io.swagger.models.parameters.Parameter;
import io.swagger.parser.SwaggerParser;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class GroupOfTitledPane extends Application {
Stage stage;
String ppaths[];
String methods[];
int i=0;
@Override
public void start(Stage stage) throws MalformedURLException {
//URL url= new URL(index.locationTextField.getText());
//System.out.println(url);
Swagger swagger = new SwaggerParser().read("https://petstore.swagger.io/v2/swagger.json");
Map<String, Path> paths = swagger.getPaths();
// Create Root Pane.
VBox root = new VBox();
root.setPadding(new Insets(20, 10, 10, 10));
for (Map.Entry<String, Path> p : paths.entrySet()) {
Path path = p.getValue();
Map<HttpMethod, Operation> operations = path.getOperationMap();
for (java.util.Map.Entry<HttpMethod, Operation> o : operations.entrySet()) {
CheckBox chk = new CheckBox();
chk.setText((o.getKey()).toString()+" : "+(p.getKey()).toString()+" : "+o.getValue().getSummary());
TitledPane firstTitledPane = new TitledPane() ;
BorderPane bPane = new BorderPane();
bPane.setRight(chk);
firstTitledPane.setGraphic(bPane);
VBox content1 = new VBox();
System.out.println("===");
System.out.println("PATH:" + p.getKey());
System.out.println("Http method:" + o.getKey());
System.out.println("Summary:" + o.getValue().getSummary());
content1.getChildren().add(new Label("Summary:" + o.getValue().getSummary()));
System.out.println("Parameters number: " + o.getValue().getParameters().size());
content1.getChildren().add(new Label("Parameters number: " + o.getValue().getParameters().size()));
for (Parameter parameter : o.getValue().getParameters()) {
System.out.println(" - " + parameter.getName());
content1.getChildren().add(new Label(" - " + parameter.getName()));
}
System.out.println("Responses:");
content1.getChildren().add(new Label("Responses:"));
for (Map.Entry<String, Response> r : o.getValue().getResponses().entrySet()) {
System.out.println(" - " + r.getKey() + ": " + r.getValue().getDescription());
content1.getChildren().add(new Label(" - " + r.getKey() + ": " + r.getValue().getDescription()));
}
firstTitledPane.setContent(content1);
root.getChildren().addAll(firstTitledPane);
}
}
ScrollPane scrollPane = new ScrollPane();
scrollPane.setFitToHeight(true);
scrollPane.setFitToWidth(true);
Button terminer = new Button("Terminer");
root.getChildren().addAll(terminer);
root.setAlignment(Pos.BOTTOM_RIGHT);
root.setSpacing(10);
scrollPane.setContent(root);
Scene scene = new Scene(scrollPane, 600, 400);
stage.setScene(scene);
stage.show();
terminer.setOnAction(event -> {
});
}
public static void main(String[] args) {
Application.launch(args);
}
}