java - StyleManager not applying CSS properly -
i'm encountering issue stylemanager in java 1.8.0_25. if apply css file scene directly css appear properly. however, if try , use stylemanager apply css file across scenes, css not applied.
here's simple program demonstrate issue
public class test extends application { public static void main(string[] args) { launch(args); } @override public void start(stage primarystage) throws exception { application.setuseragentstylesheet(null); parent node = new fxmlloader(getclass().getresource("testing.fxml")).load(); scene scene = new scene(node); // stylemanager.getinstance().adduseragentstylesheet("tabpanetest.css"); scene.getstylesheets().add("tabpanetest.css"); primarystage.setscene(scene); primarystage.show(); } }
testing.fxml:
<?xml version="1.0" encoding="utf-8"?> <?import java.net.*?> <?import java.lang.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <vbox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <children> <tabpane maxheight="-infinity" maxwidth="-infinity" minheight="-infinity" minwidth="-infinity" prefheight="400.0" prefwidth="600.0" tabclosingpolicy="unavailable"> <tabs> <tab text="untitled tab 1"> <content> <anchorpane minheight="0.0" minwidth="0.0" prefheight="180.0" prefwidth="200.0" /> </content> </tab> <tab text="untitled tab 2"> <content> <anchorpane minheight="0.0" minwidth="0.0" prefheight="180.0" prefwidth="200.0" /> </content> </tab> </tabs> </tabpane> </children> </vbox>
tabpanetest.css:
.tab-pane .tab { -fx-padding: 3 6 1 6; -fx-border-style: none; -fx-border-color: transparent; -fx-border-width: 0; -fx-border-insets: 2; -fx-background-radius: 3 3 0 0; -fx-background-insets: 0 2 0 2; -fx-background-color: linear-gradient(green 80%, blue 100%); }
without using stylemanager, it's suppose like:
however, when comment out applying css directly scene , using stylemanager instead get:
has experienced issue stylemanager? unfortunately, have big application, uses stylemanager apply css scenes
call stylemanager.getinstance().adduseragentstylesheet("tabpanetest.css");
after primarystage.show();
.
i encountered same issue since java 8u40 , fixed way. unfortunately have not found public api adding global stylesheet, too.
Comments
Post a Comment