在Swing中,有一些外观和感觉是Java的一部分,例如:
跨平台:
特定于平台的:
Java8的供应看上去像Swing一样适合JavaFX吗?(我不问特定的外观和感觉,我一般会问,除了默认的外观之外,是否还有其他的外观和感觉)
发布于 2015-03-14 15:02:13
我将用对这个问题的答复的摘要和我自己做的一些研究来回答我自己的问题:
可以使用以下命令在Modena和里海样式表之间切换:
setUserAgentStylesheet(STYLESHEET_CASPIAN); // Switches to "Caspian"
setUserAgentStylesheet(STYLESHEET_MODENA); // Switches to "Modena"请注意:
setUserAgentStylesheet(String url)是类Application的一个方法。STYLESHEET_CASPIAN和STYLESHEET_MODENA是Application的类成员。Application线程上调用。STYLESHEET_CASPIAN和STYLESHEET_MODENA包含 url 。您可以使用该方法使用自己的样式表,将它传递给样式表。- For example, if I created a stylesheet named **DarkTheme.css** and placed it in the project directory, under **src/resources**, I would use the following code to apply it: `setUserAgentStylesheet(this.getClass().getResource("resources/DarkTheme.css").toExternalForm());`
- If you just want to **extend** the current stylesheet, and not to define it all from scratch, you may use instead: `scene.getStylesheets().add(this.getClass().getResource("resources/DarkTheme.css").toExternalForm());`
https://stackoverflow.com/questions/28991389
复制相似问题