在使用 IntelliJ Community Edition 2021.2 运行 Java 程序时,当显示 FileChooser 对话框时,我看到控制台输出“java[934:22850] +[CATransaction synchronize] called within transaction”。该对话框似乎工作正常,但我对消息感到困惑。
MacOS 13.0.1(文图拉); IntelliJ 社区版 2021.2; JDK 15.0.2; JavaFX 15.0.1+1
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import java.io.*;
public class Main extends Application {
// ..................... and now it's time for the main routine .....................
@Override
public void start(Stage primaryStage) {
// we need a FileChooser
FileChooser myChooser = new FileChooser();
// set up a controlled exit
primaryStage.setOnCloseRequest(e -> {
e.consume();
primaryStage.close();
});
// define the main scene's building blocks
VBox root = new VBox(5); // the spacing is between each element in the VBox
Scene mainScene = new Scene(root, 650, 300);
// just one button in the scene
Button websiteSupportButton = new Button("Process file");
websiteSupportButton.setMinWidth(150);
root.getChildren().add(websiteSupportButton);
websiteSupportButton.setOnAction(e -> processFiles(primaryStage, myChooser));
// and now we're ready to associate the root Scene with the primary stage, and show it
primaryStage.setX(20);
primaryStage.setY(20);
primaryStage.setScene(mainScene);
primaryStage.setTitle("Error test");
primaryStage.show();
}
// .................................. tool scenes ..................................
// stuff moved from WebsiteSupport, and severely cut down - select an input file.
private static void processFiles(Stage myStage, FileChooser myChooser) {
File inputFile;
// need to select an input file - displaying this dialog causes multiple "java[1334:69043] +[CATransaction synchronize] called within transaction" messages
inputFile = myChooser.showOpenDialog(myStage);
if (inputFile != null) {
System.out.println(" file processed");
}
}
// .......................................... standard stuff ..........................................
public static void main(String[] args) {
launch(args);
}
}
最佳答案
我试过你的代码:
- OS X(英特尔)13.0.1
- JavaFX 19
- OpenJDK 19.0.1
它收到了相同的错误消息(一次调用多次):
java[34308:361725] +[CATransaction synchronize] called within transaction
我相信每次在此配置中调用文件选择器 showOpenDialog
方法时都会发生这种情况。复制执行问题的最小示例是:
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
public class FileChooserCATransactionLogGeneratorApp extends Application {
@Override
public void start(Stage stage) {
stage.setScene(new Scene(new Group()));
stage.show();
FileChooser myChooser = new FileChooser();
myChooser.showOpenDialog(stage);
}
public static void main(String[] args) {
launch(args);
}
}
我建议提交 bug report .
如果您确实提交了错误报告并生成了错误 ID,您可以将错误报告的链接添加为对此答案的评论或编辑。
关于intellij-idea - 显示 FileChooser 对话框时为 "java[934:22850] +[CATransaction synchronize] called within transaction",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74859461/