import com.sun.javafx.runtime.VersionInfo; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; 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.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; /** * * @author cementovoz */ public class JavaFXApplication2 extends Application { @Override public void start(Stage stage) throws Exception { final String STYLE = "-fx-border-color:blue;-fx-border-width:15;"; final Accordion acc1 = createAccordion(); acc1.setStyle(STYLE); final Accordion acc2 = createAccordion(); acc2.setStyle(STYLE); ScheduledExecutorService service = Executors.newScheduledThreadPool(1); VBox root = new VBox(20); root.setFillWidth(false); StackPane p1 = new StackPane(); StackPane p2 = new StackPane(); p1.getChildren().add(acc1); p2.getChildren().add(acc2); root.getChildren().addAll(new Button(), p1, p2); Scene scene = new Scene(root, 500, 500); stage.setScene(scene); stage.show(); stage.setTitle(VersionInfo.getRuntimeVersion()); } /** * The main() method is ignored in correctly deployed JavaFX application. * main() serves only as fallback in case the application can not be * launched through deployment artifacts, e.g., in IDEs with limited FX * support. NetBeans ignores main(). * * @param args the command line arguments */ public static void main(String[] args) { launch(args); } private Accordion createAccordion() { TitledPane pane1 = new TitledPane(); pane1.setText("title 1\nLong text long text"); pane1.setContent(new Rectangle(100, 40, Color.SKYBLUE)); pane1.setFocusTraversable(false); TitledPane pane2 = new TitledPane(); pane2.setText("title 2\nLong text long text"); pane2.setContent(new Rectangle(100, 40, Color.BLUEVIOLET)); Accordion acc = new Accordion(); acc.getPanes().addAll(pane1, pane2); acc.setExpandedPane(pane2); pane2.setAnimated(false); pane2.setFocusTraversable(false); acc.setFocusTraversable(false); return acc; } }