- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用设置为 -1.0 的指示器进度来显示 loginprocess
运行时的一些加载。但是当我按下 Enter 按钮并使用 loginProcess
启动我的执行程序时,即使我使用 Plataform.runLater
设置可见,我的界面仍保持卡住
我的 ProgressIndicator
。
我的按钮事件:
public void initManager(final LoginManager loginManager) {
btnEntrar.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
String email = loginTxtField.getText().trim();
String token = tokenTxtField.getText().trim();
if (email.equals("")) {
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", "Digite o e-mail");
}
});
return;
}
try {
Future future = loginProcess(email, token);
showLoginLoading(future);
future.get();
if (!loginGatewayFailed && !loginTargetAppFailed) {
Login loginTargetApp = new Login(email, null, null);
loginManager.autheticated(loginTargetApp, loginGateway, gateway, file);
} else {
if (loginTargetAppFailed) {
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", loginTargetAppFailedCause);
}
});
} else {
if (loginGatewayFailed) {
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", loginGatewayFailedCause);
}
});
}
}
}
} catch (final Exception ex) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, ex.getMessage());
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", ex.getMessage());
}
});
}
}
});
}
我的登录过程:
public Future<?> loginProcess(String email, String token) throws Exception {
// MY PROCESS
return Executors.newSingleThreadExecutor().submit(new LoginTask(this, email, token));
} catch (Exception e) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, e.getMessage());
throw e;
}
}
方法显示登录加载:
private void showLoginLoading(Future future) {
while (!future.isDone()) {
Platform.runLater(new Runnable() {
@Override
public void run() {
progressInd.setVisible(true);
// progressInd.setProgress(-1.0);
}
});
}
}
最佳答案
问题出在线程管理上。我试图在主 FX View 运行的同一线程中执行登录指令。我想通了使用 Platform.isFxApplicationThread();如果调用线程是 JavaFX 应用程序线程,则返回 true。
为了解决我的问题,我只需要创建一个新线程来运行我的所有登录指令,如您在下面的示例中所见:
public void initManager(final LoginManager loginManager) {
btnEntrar.setOnAction(new EventHandler<ActionEvent>() {
boolean mainThread = Platform.isFxApplicationThread();
System.out.println("This is the main Thread: " + mainThread);
Platform.runLater(new Runnable() {
@Override
public void run() {
progressInd.setVisible(true);
}
});
new Thread() {
public void run() {
boolean mainThread = Platform.isFxApplicationThread();
System.out.println("This is the main Thread: " + mainThread);
String email = loginTxtField.getText().trim();
String token = tokenTxtField.getText().trim();
if (email.equals("")) {
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", "Digite o e-mail");
}
});
return;
}
try {
Future future = loginProcess(email, token);
// showLoginLoading(future);
future.get();
if (!loginGatewayFailed && !loginTargetAppFailed) {
Login loginTargetApp = new Login(email, null, null);
loginManager.autheticated(loginTargetApp, loginGateway, gateway, file);
} else {
if (loginTargetAppFailed) {
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", loginTargetAppFailedCause);
}
});
} else {
if (loginGatewayFailed) {
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", loginGatewayFailedCause);
}
});
}
}
}
} catch (final Exception ex) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, ex.getMessage());
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", ex.getMessage());
}
});
}
}
}.start();
});
}
关于java - 按下按钮时 ProgressIndicator 卡住。 JavaFX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14878032/
我正在使用 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
我是一名优秀的程序员,十分优秀!