【发布时间】:2017-03-10 09:26:37
【问题描述】:
我一直在尝试删除 ProgressIndicator 下方的百分比文本,但没有成功。我发现了几个提到这一点并尝试了接受的答案,但它不起作用
使用 Java 8 更新 121
package com.company.mytest;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class ProgressApp extends Application {
public static void main(String[] args) {
launch(args);
}
/* (non-Javadoc)
* @see javafx.application.Application#start(javafx.stage.Stage)
*/
@Override
public void start(Stage stage) throws Exception {
ProgressIndicator progress = new ProgressIndicator();
progress.setProgress(0.5f);
StackPane root = new StackPane();
root.getChildren().add(progress);
Scene scene = new Scene(root);
scene.getStylesheets()
.add(getClass().getResource("progress.css").toExternalForm());
stage.setScene(scene);
stage.setWidth(300);
stage.setHeight(300);
stage.setTitle("JavaFX 8 app");
stage.show();
}
}
我知道 CSS 已加载,因为我可以更改百分比字体大小。这是 progress.css 文件的 CSS 内容。
.progress-indicator .percentage {
visibility: hidden;
}
【问题讨论】: