Class TabLine

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.control.Control
atlantafx.base.controls.TabLine
All Implemented Interfaces:
javafx.css.Styleable, javafx.event.EventTarget, javafx.scene.control.Skinnable

public class TabLine extends javafx.scene.control.Control
The TabLine is a more customizable alternative to the JavaFX TabPane component.

Removed features:

  • Orientation: TabLine can only be placed horizontally.
  • Content view: You no longer use the Tab.setContent(Node) method. Instead, you can subscribe to SelectionModel changes and modify the application view as needed, such as switching the StackPane layer.
  • Automatic dropdown menu display when the tabs overflow the viewport size. Instead, use TabMenuButton (or any control of your choice) and place it in one of the two custom slots on the right or left side of the tabs.
  • Added features:

  • Allows for pinning tabs via Tab.pinnedProperty().
  • Enables the placement of custom controls through the leftNodeProperty() and rightNodeProperty().
  • Closing policy is now an interface rather than an enum, allowing you to implement your own policy to determine whether a tab can be closed or pinned. See Tab.ClosingPolicy.
  • Tab.ResizePolicy to define the strategy for calculating the width of tabs, including viewport overflow behavior.
  • Reusable TabContextMenu, allowing you to attach a single context menu instance to any tab.
  • Simplified and improved control layout to support additional styling features available, such as a hover effect for the close button.
  • Example:

     var tabLine = new TabLine();
     tabLine.getTabs().setAll(
         new Tab("#first", "First"),
         new Tab("#second", "Second")
     );
     tabLine.setTabDragPolicy(Tab.DragPolicy.REORDER);
     tabLine.setTabResizePolicy(Tab.ResizePolicy.FIXED_WIDTH);
     tabLine.setTabClosingPolicy(Tab.ClosingPolicy.SELECTED_TAB);
    
     var tabContent1 = new Label("First Tab");
     var tabContent2 = new Label("Second Tab");
    
     var contentArea = new BorderPane(label);
     tabLine.getSelectionModel().selectedItemProperty().subscribe(tab -> {
         var content = switch (tab.getId()) {
             case "#first" -> tabContent1;
             case "#second" -> tabContent2;
             default -> null;
         };
         contentArea.setCenter(content);
     });