[TabPane] Support reordering of Tabs within a TabPane

XMLWordPrintable

    • Type: CSR
    • Resolution: Approved
    • Priority: P4
    • 10
    • Component/s: javafx
    • None
    • behavioral
    • minimal
    • The default behavior of a TabPane will not be altered. Setting the drag policy to REORDER will allow user to reorder the tabs using mouse press-drag-release gesture.
    • Java API
    • JDK

      Summary

      Add support for reordering of the tabs within a TabPane.

      Problem

      Tabs added to a TabPane are displayed in the same sequence as they are added to the TabPane. Once added, the tabs cannot be visually reordered using mouse. It is a very common use case to reorder the tabs in an TabPane based application.

      Solution

      • Provide an optional property to enable reordering within the TabPane.
      • As default behavior the tabs cannot be reordered. This will not alter the behavior of existing applications.
      • Fix: http://cr.openjdk.java.net/~arapte/fx/8187074/webrev.08/

      Specification

      TabDragPolicy property and enum are added to TabPane control:

      /**
       * The drag policy for the tabs. The policy can be changed dynamically.
       *
       * @defaultValue TabDragPolicy.FIXED
       * @return The tab drag policy property
       * @since 10
       */
      public final ObjectProperty<TabDragPolicy> tabDragPolicyProperty() {}
      public final void setTabDragPolicy(TabDragPolicy value) {}
      public final TabDragPolicy getTabDragPolicy() {}
      
      /**
       * This enum specifies drag policies for tabs in a TabPane.
       *
       * @since 10
       */
      public enum TabDragPolicy {
      	/**
      	 * The tabs remain fixed in their positions and cannot be dragged.
      	 */
      	FIXED,
      
      	/**
      	 * The tabs can be dragged to reorder them within the same TabPane.
      	 * Users can perform the simple mouse press-drag-release gesture on a
      	 * tab header to drag it to a new position. A tab can not be detached
      	 * from its parent TabPane.
      	 * <p>After a tab is reordered, the {@link #getTabs() tabs} list is
      	 * permuted to reflect the updated order.
      	 * A {@link javafx.collections.ListChangeListener.Change permutation
      	 * change} event is fired to indicate which tabs were reordered. This
      	 * reordering is done after the mouse button is released. While a tab
      	 * is being dragged, the list of tabs is unchanged.</p>
      	 */
      	REORDER
      }
      

            Assignee:
            Ambarish Rapte
            Reporter:
            Ambarish Rapte
            Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: