javafx - ProgressIndicator 在不确定模式下花费大量 CPU (JavaFX)
问题描述
我的节点显示连接到我的 PC 的设备。在未连接时,显示处于不确定模式 (progress=-1) 的 progressIndicator(并显示消息“设备未打开”)。但我对 CPU 使用率有疑问 - 虽然 progressIndicator 不确定,但 CPU 使用率非常高(接近 20%)。当我打开设备时,progressIndicator 被隐藏,CPU 使用率变为 1% 或 2%。即使在这个示例中,一个 progressIndicator 处于不确定模式,我的 CPU 使用率也接近 12%:
import javafx.application.Application;
import javafx.scene.CacheHint;
import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class Del extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Scene scene = new Scene(getTestGridPane());
primaryStage.setTitle("Welcome to JavaFX!");
primaryStage.setScene(scene);
primaryStage.sizeToScene();
primaryStage.show();
}
public GridPane getTestGridPane() {
GridPane gridPane = new GridPane();
ProgressIndicator mp = new ProgressIndicator();
mp.setCache(true);
mp.setCacheHint(CacheHint.SPEED);
mp.setCacheShape(true);
gridPane.add(mp, 0, 0);
return gridPane;
}
}
如何长时间使用处于不确定状态的progressIndicator?
解决方案
推荐阅读
- mysql - XAMPP MAC OSx - 使用外部 USB 驱动器存储 MySQL
- c++ - 隐藏在 C++ 中的函数
- sql - 如何插入同名的xml节点并根据属性忽略
- python - AttributeError:“TweetSerializer”对象没有属性“get_likes”
- python - 如何在odoo表单视图中为字段设置边距?
- java - 螺旋钻石印花图案
- python - 在 Pycharm 中加载原生 TensorFlow 运行时失败
- sql - 动态 SQL 中的变量声明和 EXEC 命令不起作用
- vue.js - 如何缓存组件 dom 和状态并根据我的逻辑进行渲染?
- python - 无法从 pandas_ml 的“sklearn.preprocessing”导入名称“Imputer”