java 是否可以设置 ProgressIndicator 的样式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11184255/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to style ProgressIndicator?
提问by Rogach
I like ProgressIndicator, except I'd like to change it's color and circle width. Is it possible (with css or without)?
我喜欢 ProgressIndicator,但我想改变它的颜色和圆圈宽度。是否有可能(使用 css 或不使用)?
回答by Sergey Grinev
Of course, it's very easy.
当然,这很容易。
You can find all related methods and styles in doc:
您可以在文档中找到所有相关的方法和样式:
- API: http://docs.oracle.com/javafx/2/api/index.html?overview-summary.html
CSS: http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#progressindicator
public class HelloProgressIndicator extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { Pane root = new Pane(); Scene scene = new Scene(root, 200, 200); ProgressIndicator pi = new ProgressIndicator(.314); // changing color with css pi.setStyle(" -fx-progress-color: red;"); // changing size without css pi.setMinWidth(150); pi.setMinHeight(150); root.getChildren().add(pi); stage.setScene(scene); stage.show(); } }
- API:http: //docs.oracle.com/javafx/2/api/index.html?overview-summary.html
CSS:http: //docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#progressindicator
public class HelloProgressIndicator extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { Pane root = new Pane(); Scene scene = new Scene(root, 200, 200); ProgressIndicator pi = new ProgressIndicator(.314); // changing color with css pi.setStyle(" -fx-progress-color: red;"); // changing size without css pi.setMinWidth(150); pi.setMinHeight(150); root.getChildren().add(pi); stage.setScene(scene); stage.show(); } }