/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javafxapplication68; import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Accordion; import javafx.scene.control.Button; import javafx.scene.control.TitledPane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.scene.text.FontSmoothingType; import javafx.scene.text.TextBuilder; import javafx.stage.Stage; import javafx.util.Duration; public class JavaFXApplication68 extends Application { public static void main(String[] args) { launch(args); } double height; @Override public void start(Stage primaryStage) { TitledPane t1 = new TitledPane("Node 1", new Button("Button")); TitledPane t2 = new TitledPane("Node 2", TextBuilder.create().text("String").fontSmoothingType(FontSmoothingType.LCD).build()); TitledPane t3 = new TitledPane("Node 3", new Rectangle(120,50, Color.RED)); final Accordion accordion = new Accordion(); accordion.getPanes().add(t1); accordion.getPanes().add(t2); accordion.getPanes().add(t3); Timeline t = new Timeline(); height = accordion.getHeight(); t.getKeyFrames().addAll(new KeyFrame(Duration.ZERO), new KeyFrame(Duration.INDEFINITE)); t.currentTimeProperty().addListener(new ChangeListener(){ @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { double newHeight = accordion.getHeight(); if ( newHeight != height ){ System.out.println(height + " -> " + newHeight); height = newHeight; } } }); t.playFromStart(); Group root = new Group(); root.getChildren().add(accordion); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } }