自动完成在Javafx 11.0.2中不起作用,显示javafx.base和controlsfx未导出的错误。

huangapple go评论73阅读模式
英文:

Autocomplete in Javafx11.0.2 not working shows error of javafx.base and controlsfx not exported

问题

@FXML private TextField corporateName;
private Set 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);
}

--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&lt;String&gt; possibleSuggestion = new HashSet&lt;&gt;(Arrays.asList(_possibleSuggestion));
private String[] _possibleSuggestion ={&quot;Abc Corp&quot;, &quot;bbb corp&quot;, &quot;jags corp&quot;, &quot;test&quot;,&quot;xuz&quot;,&quot;hyatt&quot;,&quot;yak n yeti&quot;};
    

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 :

      &lt;dependency&gt;
        &lt;groupId&gt;org.burningwave&lt;/groupId&gt;
        &lt;artifactId&gt;core&lt;/artifactId&gt;
        &lt;version&gt;12.62.7&lt;/version&gt;
     &lt;/dependency&gt;

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

huangapple
  • 本文由 发表于 2020年10月20日 01:31:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/64432454.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定