/* * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javafx.scene.control; import javafx.beans.property.ObjectProperty; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; import com.sun.javafx.collections.TrackableObservableList; import com.sun.javafx.scene.control.skin.AccordionSkin; import javafx.beans.property.ObjectPropertyBase; import javafx.beans.value.WritableValue; import javafx.css.StyleableProperty; /** *
An accordion is a group of {@link TitledPane TitlePanes}. Only one TitledPane can be opened at * a time.
* *The {@link TitledPane} content in an accordion can be any {@link javafx.scene.Node} such as UI controls or groups * of nodes added to a layout container.
* *It is not recommended to set the MinHeight, PrefHeight, or MaxHeight * for this control. Unexpected behavior will occur because the * Accordion's height changes when a TitledPane is opened or closed.
* ** Accordion sets focusTraversable to false. *
* *Example: *
* TitledPane t1 = new TitledPane("T1", new Button("B1"));
* TitledPane t2 = new TitledPane("T2", new Button("B2"));
* TitledPane t3 = new TitledPane("T3", new Button("B3"));
* Accordion accordion = new Accordion();
* accordion.getPanes().addAll(t1, t2, t3);
* @since JavaFX 2.0
*/
public class Accordion extends Control {
/***************************************************************************
* *
* Constructors *
* *
**************************************************************************/
/**
* Creates a new Accordion with no TitledPanes.
*/
public Accordion() {
this((TitledPane[])null);
}
/**
* Creates a new Accordion with the given TitledPanes showing within it.
*
* @param titledPanes The TitledPanes to show inside the Accordion.
* @since JavaFX 8u40
*/
public Accordion(TitledPane... titledPanes) {
getStyleClass().setAll(DEFAULT_STYLE_CLASS);
if (titledPanes != null) {
getPanes().addAll(titledPanes);
}
// focusTraversable is styleable through css. Calling setFocusTraversable
// makes it look to css like the user set the value and css will not
// override. Initializing focusTraversable by calling applyStyle with null
// StyleOrigin ensures that css will be able to override the value.
((StyleablePropertyThe expanded {@link TitledPane} that is currently visible. While it is technically * possible to set the expanded pane to a value that is not in {@link #getPanes}, * doing so will be treated by the skin as if expandedPane is null. If a pane * is set as the expanded pane, and is subsequently removed from {@link #getPanes}, * then expanded pane will be set to null, if possible. (This will not be possible * if you have manually bound the expanded pane to some value, for example). *
*/ public final void setExpandedPane(TitledPane value) { expandedPaneProperty().set(value); } /** * Gets the expanded TitledPane in the Accordion. If the expanded pane has been * removed or there is no expanded TitledPane {@code null} is returned. * * @return The expanded TitledPane in the Accordion. */ public final TitledPane getExpandedPane() { return expandedPane.get(); } /** * The expanded TitledPane in the Accordion. * * @return The expanded TitledPane in the Accordion. */ public final ObjectProperty