- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否可以将节点用作鼠标光标?我在 ProgressIndicator 中思考。例如确定性的,让用户知道当前任务完成了多少百分比。
最佳答案
可能最可靠的方法是将光标设置为 Cursor.NONE
,并使用带有进度指示器的标签作为其图形,跟踪鼠标坐标。
我尝试使用更新后的 ImageCursor
,但什么也没有出现:我猜测图像计算速度不够快。
这是第一种技术的 SSCCE:
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.ImageCursor;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class ProgressIndicatorAsCursor extends Application {
@Override
public void start(Stage primaryStage) {
Button button = new Button("Start");
Service<Void> service = new Service<Void>() {
@Override
public Task<Void> createTask() {
return new Task<Void>() {
@Override
public Void call() throws Exception {
for (int i = 1 ; i <= 1000; i++) {
Thread.sleep(10);
updateProgress(i, 1000);
}
return null ;
}
};
}
};
button.disableProperty().bind(service.runningProperty());
button.setOnAction(e -> service.restart());
ProgressIndicator pi = new ProgressIndicator();
pi.progressProperty().bind(service.progressProperty());
Pane pane = new Pane();
// fill pane with rectangle as task progresses:
Rectangle rectangle = new Rectangle();
rectangle.setFill(Color.CORNFLOWERBLUE);
rectangle.setX(0);
rectangle.widthProperty().bind(pane.widthProperty());
rectangle.heightProperty().bind(pane.heightProperty().multiply(service.progressProperty()));
rectangle.yProperty().bind(pane.heightProperty().subtract(rectangle.heightProperty()));
pane.getChildren().add(rectangle);
Label label = new Label();
label.graphicProperty().bind(
Bindings.when(service.runningProperty())
.then(pi)
.otherwise((ProgressIndicator)null));
pane.setOnMouseEntered(e ->
pane.getChildren().add(label));
pane.setOnMouseExited(e ->
pane.getChildren().remove(label));
pane.setOnMouseMoved(e -> label.relocate(e.getX(), e.getY()));
pane.cursorProperty().bind(
Bindings.when(service.runningProperty())
.then(Cursor.NONE)
.otherwise(Cursor.DEFAULT));
BorderPane.setAlignment(button, Pos.CENTER);
BorderPane.setMargin(button, new Insets(10));
BorderPane root = new BorderPane(pane, new Rectangle(0,0,0,20), null, button, null);
primaryStage.setScene(new Scene(root, 400, 600));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
关于java - ProgressIndicator(节点)作为鼠标光标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31707935/
我正在使用 ProgressIndicator,我希望它一直旋转。如果 %-Label 不可见,那就太好了。 提前致谢! 最佳答案 请注意我认为还有其他线程也有几乎相同的问题。 但不管怎样,只要在你的
我使用“android.material.progressindicator”来在水平 View 中显示进度,但我听不到我的 XML 最佳答案 您可以使用: 使用progressIndicator
是否可以将节点用作鼠标光标?我在 ProgressIndicator 中思考。例如确定性的,让用户知道当前任务完成了多少百分比。 最佳答案 可能最可靠的方法是将光标设置为 Cursor.NONE,并使
我正在 Javafx 中设计一个多线程应用程序,并且希望有一个 TableView,其中包含每个线程的名称和进度列。经过大量研究后,我发现了一个与我试图在这里完成的类似的例子: JavaFX Upda
我想更改附加到 ProgressIndicator 的文本标签的颜色,因为默认文本颜色是黑色,而且我的背景也是黑色。 到目前为止我已经尝试过: ProgressIndicator pg = new P
我一直在尝试删除 ProgressIndicator 下面的百分比文本,但没有成功。我发现了几次对此的提及并尝试了接受的答案,但它不起作用 使用 Java 8 更新 121 package com.c
如何在 JavaFx 中实现依赖于 GUI 组件的任务? 目标是从各种 SceneGraph 组件生成报告,同时向用户呈现一些进度指示器。 我们需要 生成某个节点的快照 将其转换为 BufferedI
我喜欢 ProgressIndicator,但我想更改它的颜色和圆圈宽度。是否可能(有或没有 css)? 最佳答案 当然,这很容易。 你可以在文档中找到所有相关的方法和样式: API:http://d
我有一个长期运行的后台操作,用于将用户数据与远程 Web 服务同步,并希望向用户提供有关该操作状态的反馈。 SystemTray ProgressIndicator 在 XAML 中绑定(bind)到
我从早上就想知道如何解决这个问题。我有登录应用程序。当用户等待登录时,我想使用 processindicator。我使用了第二个线程,但它不起作用 主加载器 fxml 主 Controller @FX
我正在使用该循环从 ftp 客户端下载文件 private void download(String date){ try { FTPFile ftpFile = client
当 javafx ui 线程中完成一些繁重的工作时,是否有可能显示(旋转,而不是卡住)进度指示器? 背景故事:我必须将一个相当大的 tableView 加载到 TitledPane 中(这需要几秒钟)
我正在使用设置为 -1.0 的指示器进度来显示 loginprocess 运行时的一些加载。但是当我按下 Enter 按钮并使用 loginProcess 启动我的执行程序时,即使我使用 Plataf
我制作了一个进度指示器,它在 Manipulate 中工作得很好。我单击一个按钮,该按钮调用一个确实有效的函数 foo[],并且当它工作时,progressIndicator 会动态显示该函数正在执行
在我的应用程序中,我必须构建包含大量内容的大 Pane 。当 GUI 加载时,我将显示一个 ProgressIndicator。 我的第一个测试,我将在向 TabPane 添加大量选项卡时显示 Pro
我试图在执行异步后台 ProgressIndicator 项目加载时显示 ListView。我想要的行为是: 在开始加载 ListView 项之前,显示一个带有 indeterminate 进度的 P
在JavaFX 2中,您可以使用ProgressInidicator来显示某些后台任务正在进行中。 我想将 ProgressIndicator 显示在 GridPane 顶部的中心,以便它覆盖 Gri
我是 JavaFX 的新手。我的 JavaFX 应用程序有问题,我需要在数据库查询之前启动 ProgressIndicator(键入 INDETERMINATE)。这是我的代码的一部分: spinne
我是 Windows Phone 开发的新手。我使用以下代码创建了进度指示器。 ProgressIndicator progressIndicator = new ProgressIn
我必须遵循 ProgressIndicator 在与我实现的这个 View 关联的 ViewModel 中 private Visibility progressVisibility = Visib
我是一名优秀的程序员,十分优秀!