英文:
Autocomplete in Javafx11.0.2 not working shows error of javafx.base and controlsfx not exported
问题
@FXML private TextField corporateName;
private Set
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);
}
--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
How can I resolve this error ? Please suggest.
英文:
I am using javafx-11.0.2 and trying to use autocomplete feature.The code is like this:
@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);
}
And the VM options
is as follows:
--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
but everytime it is showing error like this :
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
How can I resolve this error ? Please suggest.
答案1
得分: 1
请参考以下链接以解决此问题:
https://dzone.com/articles/how-to-export-all-modules-to-all-modules-at-runtime-in-java
在您的项目中添加依赖:
<dependency>
<groupId>org.burningwave</groupId>
<artifactId>core</artifactId>
<version>12.62.7</version>
</dependency>
在 module-info.java 文件中添加以下内容:
requires org.burningwave.core;
在添加依赖后执行此方法:
Modules.exportAllToAll();
英文:
Please refer to the following link in order to solve this issue:
https://dzone.com/articles/how-to-export-all-modules-to-all-modules-at-runtime-in-java
Add the dependency in your project :
<dependency>
<groupId>org.burningwave</groupId>
<artifactId>core</artifactId>
<version>12.62.7</version>
</dependency>
Add the following in module-info.java file:
requires org.burningwave.core;
Execute this method after adding the dependency:
Modules.exportAllToAll();
答案2
得分: 0
你遇到的问题是--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED
只适用于 JavaFX 9 或更早的版本。
这是你要在虚拟机选项中使用的选项。
--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls
英文:
Your issues is that --add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED
works only for JavaFX 9 or less.
This is the option you want to use in your VM options.
--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论