-
Bug
-
Resolution: Fixed
-
P3
-
jfx11, 9, 10
-
b127
-
x86_64
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8268437 | jfx11.0.12 | Johan Vos | P3 | Resolved | Fixed |
ADDITIONAL SYSTEM INFORMATION :
java 10.0.2 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
OS Name: Microsoft Windows 10 Home
OS Version: 10.0.17134 Build 17134
Graphics: Intel(R) HD Graphics 630
Computer is an Inspiron 5577 Dell laptop
A DESCRIPTION OF THE PROBLEM :
When a ProgressBar is indeterminate it is supposed to animated back and forth. When the ProgressBar is part of a Stage the animation works as expected. If you add the ProgressBar to a Dialog, however, the animation appears to be stuck at the start of the animation. This appears to only affect indeterminate ProgressBars (when the progress is updated to some determinate state the visuals update appropriately). May affect other animated nodes, such as ProgressIndicator, but did not test them.
Using early access builds for OpenJDK 11 with OpenJFX 11 does not solve the issue.
Issue has related question on Stack Overflow which indicates the issue is also present on a Mac computer.
https://stackoverflow.com/questions/51392810/indeterminate-progressbar-does-not-animate-when-part-of-a-dialog-javafx-10
REGRESSION : Last worked in version 8u181
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create ProgressBar and set it to indeterminate progress
2. Add it to a Dialog (either via the graphic property or content property)
3. Display Dialog by calling dialog.show() or dialog.showAndWait()
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
To see a blue rectangle animate side-to-side to indicate indeterminate progress.
ACTUAL -
The blue rectangle displays on the left side of the ProgressBar but does not animate.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.concurrent.Task;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.stage.Modality;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
Button detButton = new Button("Launch Determinate Task");
detButton.setOnAction(ae -> {
ae.consume();
createDialog(primaryStage, true)
.showAndWait();
});
Button indetButton = new Button("Launch Indeterminate Task");
indetButton.setOnAction(ae -> {
ae.consume();
createDialog(primaryStage, false)
.showAndWait();
});
HBox btnBox = new HBox(detButton, indetButton);
btnBox.setSpacing(10);
btnBox.setAlignment(Pos.CENTER);
StackPane root = new StackPane(btnBox, createDummyProgressNode());
Scene scene = new Scene(root, 500, 300);
primaryStage.setScene(scene);
primaryStage.setTitle("ProgressBar Issue");
primaryStage.setResizable(false);
primaryStage.show();
}
private Node createDummyProgressNode() {
Label label = new Label("ProgressBar to show animation in Stage.");
ProgressBar progressBar = new ProgressBar();
progressBar.setMaxWidth(Double.MAX_VALUE);
VBox box = new VBox(label, progressBar);
box.setMaxHeight(VBox.USE_PREF_SIZE);
box.setSpacing(3);
box.setAlignment(Pos.CENTER_LEFT);
box.setPadding(new Insets(5));
StackPane.setAlignment(box, Pos.BOTTOM_CENTER);
return box;
}
private Dialog<?> createDialog(Stage owner, boolean determinate) {
Task<?> task = new BackgroundTask(determinate);
Dialog<?> dialog = new Dialog<>();
dialog.initOwner(owner);
dialog.initModality(Modality.NONE);
dialog.setTitle("Background Task - "
+ (determinate ? "Determinate" : "Indeterminate"));
dialog.getDialogPane().setPrefWidth(300);
dialog.getDialogPane().setContent(createDialogContent(task));
dialog.getDialogPane().getButtonTypes().add(ButtonType.OK);
dialog.getDialogPane().lookupButton(ButtonType.OK)
.disableProperty().bind(task.runningProperty());
dialog.setOnShown(de -> {
de.consume();
executeTask(task);
});
return dialog;
}
private Node createDialogContent(Task<?> task) {
Label label = new Label();
label.textProperty().bind(task.messageProperty());
ProgressBar progressBar = new ProgressBar();
progressBar.setMaxWidth(Double.MAX_VALUE);
progressBar.progressProperty().bind(task.progressProperty());
VBox box = new VBox(label, progressBar);
box.setSpacing(3);
box.setAlignment(Pos.CENTER_LEFT);
return box;
}
private void executeTask(Task<?> task) {
Thread thread = new Thread(task, "background-thread");
thread.setDaemon(true);
thread.start();
}
// Dummy Task to simulate long running background task
private static class BackgroundTask extends Task<Void> {
private final boolean determinate;
private BackgroundTask(boolean determinate) {
this.determinate = determinate;
}
@Override
protected Void call() throws Exception {
final int loops = 1_000;
for (int i = 0; i <= loops; i++) {
updateMessage("Running... " + i);
Thread.sleep(1L);
if (determinate) {
updateProgress(i, loops);
}
}
updateMessage("Complete");
updateProgress(loops, loops);
return null;
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround is known at this time.
FREQUENCY : always
java 10.0.2 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
OS Name: Microsoft Windows 10 Home
OS Version: 10.0.17134 Build 17134
Graphics: Intel(R) HD Graphics 630
Computer is an Inspiron 5577 Dell laptop
A DESCRIPTION OF THE PROBLEM :
When a ProgressBar is indeterminate it is supposed to animated back and forth. When the ProgressBar is part of a Stage the animation works as expected. If you add the ProgressBar to a Dialog, however, the animation appears to be stuck at the start of the animation. This appears to only affect indeterminate ProgressBars (when the progress is updated to some determinate state the visuals update appropriately). May affect other animated nodes, such as ProgressIndicator, but did not test them.
Using early access builds for OpenJDK 11 with OpenJFX 11 does not solve the issue.
Issue has related question on Stack Overflow which indicates the issue is also present on a Mac computer.
https://stackoverflow.com/questions/51392810/indeterminate-progressbar-does-not-animate-when-part-of-a-dialog-javafx-10
REGRESSION : Last worked in version 8u181
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create ProgressBar and set it to indeterminate progress
2. Add it to a Dialog (either via the graphic property or content property)
3. Display Dialog by calling dialog.show() or dialog.showAndWait()
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
To see a blue rectangle animate side-to-side to indicate indeterminate progress.
ACTUAL -
The blue rectangle displays on the left side of the ProgressBar but does not animate.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.concurrent.Task;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.stage.Modality;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
Button detButton = new Button("Launch Determinate Task");
detButton.setOnAction(ae -> {
ae.consume();
createDialog(primaryStage, true)
.showAndWait();
});
Button indetButton = new Button("Launch Indeterminate Task");
indetButton.setOnAction(ae -> {
ae.consume();
createDialog(primaryStage, false)
.showAndWait();
});
HBox btnBox = new HBox(detButton, indetButton);
btnBox.setSpacing(10);
btnBox.setAlignment(Pos.CENTER);
StackPane root = new StackPane(btnBox, createDummyProgressNode());
Scene scene = new Scene(root, 500, 300);
primaryStage.setScene(scene);
primaryStage.setTitle("ProgressBar Issue");
primaryStage.setResizable(false);
primaryStage.show();
}
private Node createDummyProgressNode() {
Label label = new Label("ProgressBar to show animation in Stage.");
ProgressBar progressBar = new ProgressBar();
progressBar.setMaxWidth(Double.MAX_VALUE);
VBox box = new VBox(label, progressBar);
box.setMaxHeight(VBox.USE_PREF_SIZE);
box.setSpacing(3);
box.setAlignment(Pos.CENTER_LEFT);
box.setPadding(new Insets(5));
StackPane.setAlignment(box, Pos.BOTTOM_CENTER);
return box;
}
private Dialog<?> createDialog(Stage owner, boolean determinate) {
Task<?> task = new BackgroundTask(determinate);
Dialog<?> dialog = new Dialog<>();
dialog.initOwner(owner);
dialog.initModality(Modality.NONE);
dialog.setTitle("Background Task - "
+ (determinate ? "Determinate" : "Indeterminate"));
dialog.getDialogPane().setPrefWidth(300);
dialog.getDialogPane().setContent(createDialogContent(task));
dialog.getDialogPane().getButtonTypes().add(ButtonType.OK);
dialog.getDialogPane().lookupButton(ButtonType.OK)
.disableProperty().bind(task.runningProperty());
dialog.setOnShown(de -> {
de.consume();
executeTask(task);
});
return dialog;
}
private Node createDialogContent(Task<?> task) {
Label label = new Label();
label.textProperty().bind(task.messageProperty());
ProgressBar progressBar = new ProgressBar();
progressBar.setMaxWidth(Double.MAX_VALUE);
progressBar.progressProperty().bind(task.progressProperty());
VBox box = new VBox(label, progressBar);
box.setSpacing(3);
box.setAlignment(Pos.CENTER_LEFT);
return box;
}
private void executeTask(Task<?> task) {
Thread thread = new Thread(task, "background-thread");
thread.setDaemon(true);
thread.start();
}
// Dummy Task to simulate long running background task
private static class BackgroundTask extends Task<Void> {
private final boolean determinate;
private BackgroundTask(boolean determinate) {
this.determinate = determinate;
}
@Override
protected Void call() throws Exception {
final int loops = 1_000;
for (int i = 0; i <= loops; i++) {
updateMessage("Running... " + i);
Thread.sleep(1L);
if (determinate) {
updateProgress(i, loops);
}
}
updateMessage("Complete");
updateProgress(loops, loops);
return null;
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround is known at this time.
FREQUENCY : always
- backported by
-
JDK-8268437 Indeterminate ProgressBar does not animate if content is added after scene is set on window
- Resolved
- relates to
-
JDK-8200239 Indeterminate JavaFX ProgressBar uses too much GPU
- Open
-
JDK-8216377 JavaFX: memoryleak for initial nodes of Window
- Resolved
(1 links to)