Css JavaFx选项卡-外观与SceneBuilder不同
上下文:使用SceneBuilder构建选项卡式窗格应用程序 问题:我注意到在Scene Builder-Preview选项中看到的可视化效果&在执行程序后查看时,效果会有所不同 注意:Css JavaFx选项卡-外观与SceneBuilder不同,css,user-interface,javafx,tabs,Css,User Interface,Javafx,Tabs,上下文:使用SceneBuilder构建选项卡式窗格应用程序 问题:我注意到在Scene Builder-Preview选项中看到的可视化效果&在执行程序后查看时,效果会有所不同 注意: 我正在使用场景生成器中提供的标准选项卡和选项卡窗格选项 我使用scenebuilder10.0.0(可执行Jar)和javajdk10 我没有应用任何CSS样式,但即使是下面2个链接中建议的样式也没有帮助 期望值:程序执行后的输出与在SceneBuilder预览选项中观察到的输出相同 我提到了&但没有什么帮助
您的应用程序看起来与SceneBuilder预览不同,因为您没有使用相同的用户代理样式表主题 JavaFx应用程序默认使用其Modena主题,而您将SceneBuilder设置为使用Glion Mobile Light主题进行设计/预览(主菜单:预览->主题) JavaFx并没有随Gluon Mobile Light主题提供,如果您想使用它,您需要将您的项目设置为使用Gluon Mobile SDK/library() 另一个选项是编写自定义css:
//custom-theme.css
.tab-pane > .tab-header-area {
-fx-padding: 0;
}
.tab-pane > .tab-header-area > .tab-header-background {
-fx-background-color: #E1E1E1, white;
-fx-background-insets: 0, 0 0 1px 0;
}
.tab-pane > .tab-header-area > .headers-region > .tab {
-fx-background-color: white;
-fx-background-insets: 0 0 1px 0;
-fx-padding: 1.5em 1em;
}
.tab-pane > .tab-header-area > .headers-region > .tab >.tab-container >.tab-label {
-fx-text-fill: #63B5F6;
}
.tab-pane > .tab-header-area > .headers-region > .tab:selected {
-fx-background-color: #2092ED, white;
-fx-background-insets: 0, 0 0 2px 0;
}
.tab-pane > .tab-header-area > .headers-region > .tab:selected >.tab-container >.tab-label {
-fx-text-fill: #2095F3;
}
.tab-pane > .tab-header-area > .headers-region > .tab:selected >.tab-container >.focus-indicator {
-fx-opacity: 0;
}
将文件添加到您的项目中(将其放在“src/main/resources”或类路径中的其他位置),并将其应用到您的应用程序:
scene.getStylesheets().add("custom-theme.css");
您的应用程序看起来与SceneBuilder预览不同,因为您没有使用相同的用户代理样式表主题 JavaFx应用程序默认使用其Modena主题,而您将SceneBuilder设置为使用Glion Mobile Light主题进行设计/预览(主菜单:预览->主题) JavaFx并没有随Gluon Mobile Light主题提供,如果您想使用它,您需要将您的项目设置为使用Gluon Mobile SDK/library() 另一个选项是编写自定义css:
//custom-theme.css
.tab-pane > .tab-header-area {
-fx-padding: 0;
}
.tab-pane > .tab-header-area > .tab-header-background {
-fx-background-color: #E1E1E1, white;
-fx-background-insets: 0, 0 0 1px 0;
}
.tab-pane > .tab-header-area > .headers-region > .tab {
-fx-background-color: white;
-fx-background-insets: 0 0 1px 0;
-fx-padding: 1.5em 1em;
}
.tab-pane > .tab-header-area > .headers-region > .tab >.tab-container >.tab-label {
-fx-text-fill: #63B5F6;
}
.tab-pane > .tab-header-area > .headers-region > .tab:selected {
-fx-background-color: #2092ED, white;
-fx-background-insets: 0, 0 0 2px 0;
}
.tab-pane > .tab-header-area > .headers-region > .tab:selected >.tab-container >.tab-label {
-fx-text-fill: #2095F3;
}
.tab-pane > .tab-header-area > .headers-region > .tab:selected >.tab-container >.focus-indicator {
-fx-opacity: 0;
}
将文件添加到您的项目中(将其放在“src/main/resources”或类路径中的其他位置),并将其应用到您的应用程序:
scene.getStylesheets().add("custom-theme.css");
欣赏这些输入。错过了那张支票。感谢您的支持。我错过了那张支票。