如何在TabPane中隐藏TabBar?

Dip*_*ipu 7 tabs javafx fxml

我正在尝试使用构建下一个/上一个窗口TabPane.我决定使用,TabPane因为它很容易在SceneBuilder中使用和设计.在开始FO的应用程序,我用这个隐藏的TabBar的现在-

tabPane.setTabMinHeight(-10);
tabPane.setTabMaxHeight(-10);
Run Code Online (Sandbox Code Playgroud)

TabPane在此之后的外观 -

在此输入图像描述

如您所见,TabBar仍然只有一小部分(在标题栏下方).我怎样才能完全隐藏它,这样我的TabPane看起来就像一个普通的Pane但是它的所有功能都完好无损?

Jam*_*s_D 9

使用TabPane隐藏选项卡作为向导类型的界面是一个有趣的想法,我没有想到并认为我喜欢.

您可以在外部CSS文件中使用以下内容隐藏选项卡:

.tab-pane {
    -fx-tab-max-height: 0 ;
} 
.tab-pane .tab-header-area {
    visibility: hidden ;
}
Run Code Online (Sandbox Code Playgroud)

这是一个SSCCE.在这里我给了选项卡窗格CSS类wizard.

import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class TabPaneAsWizard extends Application {

    @Override
    public void start(Stage primaryStage) {
        TabPane tabPane = new TabPane();
        tabPane.getStyleClass().add("wizard");
        for (int i = 1; i<=10; i++) {
            tabPane.getTabs().add(createTab(i));
        }
        Button previous = new Button("Previous");
        previous.setOnAction(e -> 
            tabPane.getSelectionModel().select(tabPane.getSelectionModel().getSelectedIndex()-1));
        previous.disableProperty().bind(tabPane.getSelectionModel().selectedIndexProperty().lessThanOrEqualTo(0));
        Button next = new Button("Next");
        next.setOnAction(e ->
            tabPane.getSelectionModel().select(tabPane.getSelectionModel().getSelectedIndex()+1));
        next.disableProperty().bind(
                tabPane.getSelectionModel().selectedIndexProperty().greaterThanOrEqualTo(
                        Bindings.size(tabPane.getTabs()).subtract(1)));

        HBox buttons = new HBox(20, previous, next);
        buttons.setAlignment(Pos.CENTER);

        BorderPane root = new BorderPane(tabPane, null, null, buttons, null);
        Scene scene = new Scene(root, 600, 600);
        scene.getStylesheets().add("tab-pane-as-wizard.css");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    private Tab createTab(int id) {
        Tab tab = new Tab();
        Label label = new Label("This is step "+id);
        tab.setContent(label);
        return tab ;
    }

    public static void main(String[] args) {
        launch(args);
    }
}
Run Code Online (Sandbox Code Playgroud)

标签窗格-AS-wizard.css:

.wizard {
    -fx-tab-max-height: 0 ;
} 
.wizard .tab-header-area {
    visibility: hidden ;
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述