import com.sun.javafx.runtime.VersionInfo; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import javafx.application.Application; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Accordion; import javafx.scene.control.Button; import javafx.scene.control.TitledPane; import javafx.scene.layout.Border; import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderStroke; import javafx.scene.layout.BorderStrokeStyle; import javafx.scene.layout.BorderWidths; import javafx.scene.layout.CornerRadii; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; /** * * @author cementovoz */ public class AccordionApp extends Application { final String STYLE = "-fx-border-color:green blue yellow red;-fx-border-width:10;"; @Override public void start(Stage stage) throws Exception { BorderPane root = new BorderPane(); final Accordion a1 = createAcc(); final Accordion a2 = createAcc(); BorderStroke bs = new BorderStroke( Color.GREEN, Color.BLUE, Color.YELLOW, Color.RED, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(10), Insets.EMPTY ); final Border border = new Border(bs); a1.setBorder(border); ScheduledExecutorService service = Executors.newScheduledThreadPool(1); a2.setStyle(STYLE); Button b = new Button("Set borders"); b.setOnAction(new EventHandler() { @Override public void handle(ActionEvent t) { a2.setStyle(STYLE); a1.setBorder(border); System.out.println("Set borders"); } }); root.setCenter(new VBox(0){{getChildren().addAll(a1, a2); setFillWidth(false);}}); root.setBottom(b); Scene scene = new Scene(root, 300, 300); stage.setScene(scene); stage.show(); stage.setTitle(VersionInfo.getRuntimeVersion()); } /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } private Accordion createAcc() { 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; } }