如何删除TabPane背景阴影 [英] How to remove TabPane background shadow

查看:62
本文介绍了如何删除TabPane背景阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

找到,我可以使用以下方法删除TabPane的背景CSS.但是如何使用setStyle做到这一点?

I found that I can remove the background of TabPane using CSS. But how I can do this by using setStyle?

    TabPane tabPane = new TabPane();
    tabPane.setStyle("-fx-effect: null;");

EDIT

EDIT

public class clicen extends Application
{


    @Override
    public void start(Stage primaryStage)
    {

        final Label label = new Label("New Connection");
        label.setFont(new Font("Arial", 20));
        Stage dialog = new Stage();

        dialog.initModality(Modality.APPLICATION_MODAL);
        dialog.initOwner(primaryStage);


        GridPane gridPane = new GridPane();
        //gridPane.setGridLinesVisible(true);
        gridPane.setPadding(new Insets(25));
        gridPane.setHgap(30);
        gridPane.setVgap(30);

        TabPane tabPane = new TabPane();

        Tab tabConn = new Tab("General");
        tabConn.setStyle("-fx-font-size: 12pt;");
        tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
        Tab tabConnAdv = new Tab("Advanced");
        tabConnAdv.setStyle("-fx-font-size: 12pt;");
        tabPane.getTabs().add(tabConn);
        tabPane.getTabs().add(tabConnAdv);

        Text ncn = new Text("New Connection Properties");
        ncn.setFont(new Font("Arial", 20));

        /// internal grid pane

        GridPane ingridPane = new GridPane();
        //ingridPane.setGridLinesVisible(true);
        ingridPane.setPadding(new Insets(25));
        ingridPane.setHgap(30);
        ingridPane.setVgap(30);

        // internal gridpane
        Text textHost = new Text("Host");
        ingridPane.add(textHost, 0, 1);
        TextField hostIn = new TextField();
        ingridPane.add(hostIn, 1, 1);
        Text textUsername = new Text("Username");
        ingridPane.add(textUsername, 0, 2);
        TextField usernameIn = new TextField();
        ingridPane.add(usernameIn, 1, 2);
        Text taxtPassword = new Text("Password");
        ingridPane.add(taxtPassword, 0, 3);
        TextField passwdIn = new TextField();
        ingridPane.add(passwdIn, 1, 3);
        Text textPort = new Text("Port number");
        ingridPane.add(textPort, 0, 4);
        TextField portIn = new TextField();
        ingridPane.add(portIn, 1, 4);

        Button btnConnect = new Button("Connect");
        btnConnect.setStyle("-fx-background-color:\n"
                + "        rgba(0,0,0,0.08),\n"
                + "        linear-gradient(#9a9a9a, #909090),\n"
                + "        linear-gradient(white 0%, #f3f3f3 50%, #ececec 51%, #f2f2f2 100%);\n"
                + "    -fx-background-insets: 0 0 -1 0,0,1;\n"
                + "    -fx-background-radius: 4,4,3;\n"
                + "    -fx-padding: 7 36 6 36;\n"
                + "    -fx-text-fill: #242d35;\n"
                + "    -fx-font-size: 13px;");

        btnConnect.setOnAction(new EventHandler<ActionEvent>()
        {
            @Override
            public void handle(ActionEvent event)
            {
                System.exit(0);
            }
        });

        Button btnCancel = new Button("Cancel");
        btnCancel.setStyle("-fx-background-color:\n"
                + "        rgba(0,0,0,0.08),\n"
                + "        linear-gradient(#9a9a9a, #909090),\n"
                + "        linear-gradient(white 0%, #f3f3f3 50%, #ececec 51%, #f2f2f2 100%);\n"
                + "    -fx-background-insets: 0 0 -1 0,0,1;\n"
                + "    -fx-background-radius: 4,4,3;\n"
                + "    -fx-padding: 7 36 6 36;\n"
                + "    -fx-text-fill: #242d35;\n"
                + "    -fx-font-size: 13px;");

        btnCancel.setOnAction(new EventHandler<ActionEvent>()
        {
            @Override
            public void handle(ActionEvent event)
            {
                System.exit(0);
            }
        });


        tabConn.setContent(ingridPane);

        HBox hbox = new HBox(6);
        hbox.setSpacing(10);
        hbox.getChildren().add(btnConnect);
        hbox.getChildren().add(btnCancel);
        hbox.setAlignment(Pos.CENTER);

        gridPane.add(ncn, 0, 0);
        gridPane.add(tabPane, 0, 1);
        gridPane.add(hbox, 0, 2);
        gridPane.setAlignment(Pos.CENTER);

        Color bColor = Color.web("F5F5F5", 1.0);
        // Stage
        Scene scene = new Scene(gridPane, 800, 500, Color.WHITE);
        dialog.setScene(scene);
        dialog.setTitle("New Connection");
        //Image icon = new Image(getClass().getResource("/images/system-help.png").toExternalForm());
        //dialog.getIcons().add(icon);
        dialog.show();

        tabPane.lookup(".headers-region").setStyle("-fx-effect: null;");
    }
}

我测试了此代码.它不起作用.

I tested this code. It's not working.

SOLUTON

SOLUTON

tabPane.lookup(".tab-pane .tab-header-area .tab-header-background").setStyle("-fx-background-color: yellow;");

推荐答案

通过查找子节点并设置样式:

By looking up the sub node and setting the style:

primaryStage.show();
// after the main stage is shown
tabPane.lookup(".headers-region").setStyle("-fx-effect: null;");

这篇关于如何删除TabPane背景阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆