-
Bug
-
Resolution: Fixed
-
P3
-
8u20
-
Windows 7 64-bit
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8093486 | 9 | Kevin Rushforth | P3 | Resolved | Fixed |
As of 8u20, calling printPage() from inside an AnimationTimer callback no longer works as it did prior to that. Attempting it results in the following exception:
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Key not associated with a running event loop: java.lang.Object@2b4b3670
Here is a sample program illustrating the issue:
public class PrintBugTest extends Application {
@Override
public void start(Stage primaryStage) {
ComboBox<Printer> printerComboBox = new ComboBox<>();
printerComboBox.getItems().addAll(Printer.getAllPrinters());
printerComboBox.getSelectionModel().select(Printer.getDefaultPrinter());
Button btn = new Button("Print");
btn.setOnAction(e -> {
new AnimationTimer() {
@Override
public void handle(long l) {
stop();
Node node = new Circle(100, 200, 200);
PrinterJob job = PrinterJob.createPrinterJob();
job.setPrinter(printerComboBox.getValue());
job.printPage(node);
job.endJob();
}
}.start();
});
VBox root = new VBox();
root.setSpacing(20);
root.setAlignment(Pos.CENTER);
root.setPadding(new Insets(10,10,10,10));
root.getChildren().addAll(new HBox(new Label("Select Printer: "), printerComboBox), btn);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Key not associated with a running event loop: java.lang.Object@2b4b3670
Here is a sample program illustrating the issue:
public class PrintBugTest extends Application {
@Override
public void start(Stage primaryStage) {
ComboBox<Printer> printerComboBox = new ComboBox<>();
printerComboBox.getItems().addAll(Printer.getAllPrinters());
printerComboBox.getSelectionModel().select(Printer.getDefaultPrinter());
Button btn = new Button("Print");
btn.setOnAction(e -> {
new AnimationTimer() {
@Override
public void handle(long l) {
stop();
Node node = new Circle(100, 200, 200);
PrinterJob job = PrinterJob.createPrinterJob();
job.setPrinter(printerComboBox.getValue());
job.printPage(node);
job.endJob();
}
}.start();
});
VBox root = new VBox();
root.setSpacing(20);
root.setAlignment(Pos.CENTER);
root.setPadding(new Insets(10,10,10,10));
root.getChildren().addAll(new HBox(new Label("Select Printer: "), printerComboBox), btn);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
}
- backported by
-
JDK-8093486 Better error checking and docs if Printing or Dialogs called from Animation
-
- Resolved
-
- relates to
-
JDK-8160400 WebView can't alert from a timer
-
- Resolved
-
-
JDK-8146211 WebView can't alert from a timer
-
- Closed
-