How to set JavaFX default skin

﹥>﹥吖頭↗ 提交于 2019-12-17 13:03:27

问题


I noticed that when I run JavaFX application on JVM 7 and JVM 8 I get different default skins. How I can set the default skin to be same on every JVM?


回答1:


You can set the default skin:

@Override 
public void start(Stage stage) throws Exception {
    ....
    setUserAgentStylesheet(STYLESHEET_CASPIAN);
    ....
}

http://fxexperience.com/2013/01/modena-new-theme-for-javafx-8/




回答2:


The default stylesheet for JavaFX 2 is caspian.css. You can find it in jfxrt.jar under com.sun.javafx.scene.control.skin.caspian. This changed with JavaFX 8 and I believe the default stylesheet is named modena.css. In order to get a common stylesheet, you will have to either define your own or copy one of the defaults into your project.




回答3:


You can set your own skin by adding a style sheet.

scene.getStylesheets().add(
    getClass().getResource("my-skin.css").toExternalForm());

Unfortunately there is no default style sheet. Maybe browsing in jfxrt.jar might yield something.




回答4:


You can also run with -Djavafx.userAgentStylesheetUrl=caspian on the command line.



来源:https://stackoverflow.com/questions/17297777/how-to-set-javafx-default-skin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!