JavaFX Accordion Example

In this JavaFX source code example, we will see how to use the JavaFX Accordion control with an example.

The JavaFX Accordion control is a container control that can contain several sections internally, each of which can have its content expanded or collapsed. 

The Accordion control is implemented by the JavaFX class javafx.scene.control.Accordion.

JavaFX Accordion Example

package sample;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Accordion;
import javafx.scene.control.Button;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Main extends Application {

    public void start(Stage primaryStage) throws Exception {
        Accordion accordion = new Accordion();
        TitledPane pane1 = new TitledPane("Edit", new Button("Edit"));
        TitledPane pane2 = new TitledPane("Save", new Button("Save"));
        TitledPane pane3 = new TitledPane("Close", new Button("Close"));
        accordion.getPanes().addAll(pane1, pane2, pane3);

        VBox vBox = new VBox(accordion);
        var myScene = new Scene(vBox, 300, 250);
       // Scene myScene = new Scene(vBox);


    public static void main(String[] args) {

Free Spring Boot Tutorial - 5 Hours Full Course

Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course