简体   繁体   English

AutoCompletionBinding 无法访问类 com.sun.javafx.event.EventHandlerManager

[英]AutoCompletionBinding cannot access class com.sun.javafx.event.EventHandlerManager

I have some issues with javafx and org.controlsfx.control.textfield.TextFields .我对javafxorg.controlsfx.control.textfield.TextFields有一些问题。 I'm trying to implement a feature that would get possible user input predictions from a database so that user can only pick the "authorized" options.我正在尝试实现一个功能,该功能可以从数据库中获取可能的用户输入预测,以便用户只能选择“授权”选项。 While working with controlsfx I came across this error.在使用controlsfx时,我遇到了这个错误。

Error:错误:

Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class org.controlsfx.control.textfield.AutoCompletionBinding (in unnamed module @0x239a4ba) cannot access class com.sun.javafx.event.EventHandlerManager (in module javafx.base) because module javafx.base does not export com.sun.javafx.event to unnamed module @0x239a4ba
at org.controlsfx.control.textfield.AutoCompletionBinding.<init>(AutoCompletionBinding.java:521)
at impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding.<init>(AutoCompletionTextFieldBinding.java:107)
at impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding.<init>(AutoCompletionTextFieldBinding.java:92)
at org.controlsfx.control.textfield.TextFields.bindAutoCompletion(TextFields.java:187)
at sample.Controller.lambda$listenKey$0(Controller.java:40)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$KeyHandler.process(Scene.java:4058)
at javafx.graphics/javafx.scene.Scene$KeyHandler.access$1500(Scene.java:4004)
at javafx.graphics/javafx.scene.Scene.processKeyEvent(Scene.java:2121)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2595)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:217)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:149)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$1(GlassViewEventHandler.java:248)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:247)
at javafx.graphics/com.sun.glass.ui.View.handleKeyEvent(View.java:547)
at javafx.graphics/com.sun.glass.ui.View.notifyKey(View.java:971)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)

I've learnt that, quote Since Java Web Start is no longer a part of Java SE 11 and later, we will not look into this.我了解到, Since Java Web Start is no longer a part of Java SE 11 and later, we will not look into this. . . I don't know if it's because of that or I'm doing something wrong.我不知道是因为这个还是我做错了什么。

Here's my code:这是我的代码:

    package sample;
/**
 * Sample Skeleton for 'sample.fxml' Controller Class
 */

import java.net.URL;
import java.util.*;

import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import org.controlsfx.control.textfield.TextFields;

public class Controller{

    @FXML // ResourceBundle that was given to the FXMLLoader
    private ResourceBundle resources;

    @FXML // URL location of the FXML file that was given to the FXMLLoader
    private URL location;

    // fx:id="inputAutoComplete";
    @FXML
    private TextField inputAutoComplete;

    @FXML // This method is called by the FXMLLoader when initialization is complete
    void initialize() {
        System.out.println("XD");
        listenKey();
    }

    ArrayList<String> possibleWordSet = new ArrayList<>();

    public void listenKey(){
        databaseConnection dbconn = new databaseConnection();
        inputAutoComplete.setOnKeyPressed((event) -> {
            if(inputAutoComplete.getText().length() > 4){
                System.out.println(inputAutoComplete.getText());
                possibleWordSet = dbconn.getSuggestedData(inputAutoComplete.getText());
                System.out.println(possibleWordSet);
                TextFields.bindAutoCompletion(inputAutoComplete,possibleWordSet);
            }
        });
    }
}

Can someone give me some examples of how to implement this feature or just tell what am I doing wrong?有人可以给我一些如何实现此功能的示例,或者只是告诉我我做错了什么?

If you are using ControlsFX 11, add the following VM option to your runtime command line:如果您使用 ControlsFX 11,请将以下 VM 选项添加到您的运行时命令行:

--add-exports javafx.base/com.sun.javafx.event=org.controlsfx.controls

Note: Previous answers (on other sites and also here on SO) have suggested the following:注意:以前的答案(在其他网站上,也在 SO 上)提出了以下建议:

--add-exports javafx.base/com.sun.javafx.event=ALL-UNNAMED

However, recent versions of ControlFX appear to be modularized and the modules are no longer unnamed.但是,最近版本的 ControlFX 似乎已模块化,并且模块不再未命名。 If you are using a previous version (say, version 9), use the ALL-UNNAMED variant of the command line option.如果您使用的是以前的版本(例如版本 9),请使用命令行选项的 ALL-UNNAMED 变体。

If you ended up here and are using the maven plugin ( javafx:run ) to run your app, you can use the following configuration to get it running.如果您在这里结束并使用 maven 插件 ( javafx:run ) 来运行您的应用程序,您可以使用以下配置使其运行。

        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.4</version>
            <configuration>
                <mainClass>some.package.App</mainClass>
                 <options>
                    <option>--add-exports</option>
                    <option>javafx.base/com.sun.javafx.event=org.controlsfx.controls</option>
                 </options>
            </configuration>
        </plugin>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法访问类 com.sun.javafx.util.Utils(在模块 javafx.graphics 中)-JavaFX 和 Eclipse - Cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) - JavaFX & Eclipse 无法访问类 com.sun.javafx.scene.control.skin.resources.ControlResources(在模块 javafx.controls 中) - Cannot access class com.sun.javafx.scene.control.skin.resources.ControlResources (in module javafx.controls) 仍然收到此错误:无法访问类 com.sun.javafx.print.Units(在模块 javafx.graphics 中) - Still getting this error: Cannot access class com.sun.javafx.print.Units (in module javafx.graphics) 超类访问检查失败:类 com.sun.javafx.sg.prism.web.NGWebView - superclass access check failed: class com.sun.javafx.sg.prism.web.NGWebView Maven Apache - Terminal error [cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment] - Maven Apache - Terminal error [cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment] 无法访问 class com.sun.org.apache.xerces.internal.impl.dv.util.Z1ZEB445FA6BD5FA7778CAC - cannot access class com.sun.org.apache.xerces.internal.impl.dv.util.Base64 无法访问com.sun.tools.attach.VirtualMachine - Cannot access com.sun.tools.attach.VirtualMachine 无法子类化最终类com.sun.jmx.mbeanserver.JmxMBeanServer - Cannot subclass final class com.sun.jmx.mbeanserver.JmxMBeanServer ClassCastException:com.sun.proxy.$ProxyX 无法转换为类 - ClassCastException: com.sun.proxy.$ProxyX cannot be cast to a class 在 NetBeans 9 和 11 中打包为 DMG 图像,JDK 11 返回“typedef class com.sun.javafx.tools.ant.FXJar cannot be found using the..” - Package as DMG Image in NetBeans 9 & 11, JDK 11 returns "typedef class com.sun.javafx.tools.ant.FXJar cannot be found using the.."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM