我正在使用javafx-11.0.2并尝试使用自动完成功能。代码如下:
@FXML private TextField corporateName;
private Set<String> possibleSuggestion = new HashSet<>(Arrays.asList(_possibleSuggestion));
private String[] _possibleSuggestion ={"Abc Corp", "bbb corp", "jags corp", "test","xuz","hyatt","yak n yeti"};
public void initialize(URL location, ResourceBundle resources) {
TextFields.bindAutoCompletion(corporateName,possibleSuggestion);
}
VM options
如下:
--module-path /home/development/javafx-sdk-11.0.2/lib$Classpath$
--add-modules javafx.controls,javafx.fxml,javafx.base
--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED
但每次都显示这样的错误:
Caused by: java.lang.IllegalAccessError: class org.controlsfx.control.textfield.AutoCompletionBinding (in module controlsfx) cannot access class com.sun.javafx.event.EventHandlerManager (in module javafx.base) because module javafx.base does not export com.sun.javafx.event to module controlsfx
如何解决此错误?请建议。
2条答案
按热度按时间yzuktlbb1#
请参阅以下链接以解决此问题:https://dzone.com/articles/how-to-export-all-modules-to-all-modules-at-runtime-in-java
在项目中添加依赖项:
在www.example.com文件中添加以下内容module-info.java:
添加依赖项后执行此方法:
piv4azn72#
您的问题是
--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED
仅适用于JavaFX 9或更低版本。这是您要在VM选项中使用的选项。
--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls