Class Accordion

  • All Implemented Interfaces:
    Styleable, EventTarget, Skinnable

    public class Accordion
    extends Control

    An accordion is a group of TitlePanes. Only one TitledPane can be opened at a time.

    The TitledPane content in an accordion can be any 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
    • Property Detail

      • expandedPane

        public final ObjectProperty<TitledPane> expandedPaneProperty
        The expanded TitledPane in the Accordion.
        Returns:
        The expanded TitledPane in the Accordion.
    • Constructor Detail

      • Accordion

        public Accordion()
        Creates a new Accordion with no TitledPanes.
      • Accordion

        public Accordion​(TitledPane... titledPanes)
        Creates a new Accordion with the given TitledPanes showing within it.
        Parameters:
        titledPanes - The TitledPanes to show inside the Accordion.
        Since:
        JavaFX 8u40
    • Method Detail

      • setExpandedPane

        public final void setExpandedPane​(TitledPane value)

        The expanded TitledPane that is currently visible. While it is technically possible to set the expanded pane to a value that is not in 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 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).

        Parameters:
        value - the expanded TitledPane
      • getExpandedPane

        public final TitledPane getExpandedPane()
        Gets the expanded TitledPane in the Accordion. If the expanded pane has been removed or there is no expanded TitledPane null is returned.
        Returns:
        The expanded TitledPane in the Accordion.
      • expandedPaneProperty

        public final ObjectProperty<TitledPane> expandedPaneProperty()
        The expanded TitledPane in the Accordion.
        Returns:
        The expanded TitledPane in the Accordion.
      • getPanes

        public final ObservableList<TitledPane> getPanes()
        Gets the list of TitledPane in this Accordion. Changing this ObservableList will immediately result in the Accordion updating to display the new contents of this ObservableList.
        Returns:
        The list of TitledPane in this Accordion.
      • createDefaultSkin

        protected Skin<?> createDefaultSkin()
        Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).
        Overrides:
        createDefaultSkin in class Control
        Returns:
        new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.
      • requestLayout

        public void requestLayout()
        Requests a layout pass to be performed before the next scene is rendered. This is batched up asynchronously to happen once per "pulse", or frame of animation.

        If this parent is either a layout root or unmanaged, then it will be added directly to the scene's dirty layout list, otherwise requestParentLayout will be invoked.

        Overrides:
        requestLayout in class Parent
      • getInitialFocusTraversable

        protected Boolean getInitialFocusTraversable()
        Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value. This method is overridden as by default UI controls have focus traversable set to true, but that is not appropriate for this control.
        Overrides:
        getInitialFocusTraversable in class Control
        Returns:
        the initial focus traversable state of this control
        Since:
        9