getHostServices();找不到方法。

时间:2017-12-04 14:04:00

标签: java javafx pdf-viewer

我想使用下面的代码打开pdf文件,但方法是getHostServices();即使我有正确的进口,也找不到。

import javafx.application.HostServices;

ClinicFiles clinicFiles = (ClinicFiles) listViewClinic.getSelectionModel().getSelectedItem(); 
HostServices hostServices = getHostServices();
hostServices.showDocument(clinicFiles.getAbsolutePath());

1 个答案:

答案 0 :(得分:1)

您的课程可能不会从import javafx.application.Application; import javafx.application.HostServices; public class App extends Application { public void method(String[] args) { ClinicFiles clinicFiles = (ClinicFiles) listViewClinic.getSelectionModel().getSelectedItem(); HostServices hostServices = getHostServices(); hostServices.showDocument(clinicFiles.getAbsolutePath()); } }

延伸

例如:

$0