SwingFXUtils 显示 NoClassFoundError

SwingFXUtils shows NoClassFoundError

我试过使用函数

SwingFXUtils.fromFXImage

这会引发 NoClassFoundError 异常。我怎样才能在 Gluon 移动设备上保存图像?

SwingFXUtils Android.

不支持任何与 Swing 相关的 类

根据您的评论,您正在使用 Charm Down PicturesService 从相机中检索图像并将其显示在 ImageView 控件上:

Services.get(PicturesService.class).ifPresent(service -> 
    service.takePhoto(false).ifPresent(imageView::setImage));

现在您想将该图像保存到设备上的 private/public 存储位置。

如果您为 takePhoto 检查 API,它有一个 savePhoto 参数,您可以使用它来保存图片:

// take photo and save picture
Services.get(PicturesService.class).ifPresent(service -> 
    service.takePhoto(true).ifPresent(imageView::setImage));

现在,如果您look知道这是如何实现的,您将在图片的外部存储下找到您的图片:

File photo = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "IMG_"+ timeStamp + ".jpg");

您可以在 /sdcard/Pictures 下轻松访问该文件夹。

您也可以使用 StorageServicegetPublicStorage("Pictures"),通过目录可以检索最后添加的文件:

File picturesDir = Services.get(StorageService.class)
            .flatMap(s -> s.getPublicStorage("Pictures"))
            .orElseThrow(() -> new RuntimeException("Error retrieving public storage")); 
for (File pic : picturesDir.listFiles()) {
        System.out.println("file " + pic.getName());
}