ControlsFX的RangeSlider问题

时间:2018-08-06 13:16:51

标签: java javafx controlsfx rangeslider

我正在尝试在程序中实现RangeSlider类,但是,我收到以下错误:

Exception in Application start method
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalAccessError: class impl.org.controlsfx.behavior.RangeSliderBehavior (in unnamed module @0x74bf073e) cannot access class com.sun.javafx.scene.control.inputmap.InputMap$Mapping (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control.inputmap to unnamed module @0x74bf073e
    at impl.org.controlsfx.behavior.RangeSliderBehavior.<init>(RangeSliderBehavior.java:67)
    at impl.org.controlsfx.skin.RangeSliderSkin.<init>(RangeSliderSkin.java:95)
    at org.controlsfx.control.RangeSlider.createDefaultSkin(RangeSlider.java:194)
    at javafx.controls/javafx.scene.control.Control.doProcessCSS(Unknown Source)
    at javafx.controls/javafx.scene.control.Control.access$000(Unknown Source)
    at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Unknown Source)
    at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(Unknown Source)
    at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.doProcessCSS(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.access$400(Unknown Source)
    at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Unknown Source)
    at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(Unknown Source)
    at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.doProcessCSS(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.access$400(Unknown Source)
    at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Unknown Source)
    at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(Unknown Source)
    at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.doProcessCSS(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.access$400(Unknown Source)
    at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Unknown Source)
    at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(Unknown Source)
    at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
    at javafx.graphics/javafx.scene.Node.processCSS(Unknown Source)
    at javafx.graphics/javafx.scene.Scene.doCSSPass(Unknown Source)
    at javafx.graphics/javafx.scene.Scene.preferredSize(Unknown Source)
    at javafx.graphics/javafx.scene.Scene$2.preferredSize(Unknown Source)
    at javafx.graphics/com.sun.javafx.scene.SceneHelper.preferredSize(Unknown Source)
    at javafx.graphics/javafx.stage.Window$12.invalidated(Unknown Source)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(Unknown Source)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.set(Unknown Source)
    at javafx.graphics/javafx.stage.Window.setShowing(Unknown Source)
    at javafx.graphics/javafx.stage.Window.show(Unknown Source)
    at javafx.graphics/javafx.stage.Stage.show(Unknown Source)
    at minimalist.DoubleSliderInterface.start(DoubleSliderInterface.java:104)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
    ... 1 more
Exception running application minimalist.DoubleSliderInterface

我在Eclipse上运行Java 10时使用的是ControlsFX版本9.0.0,但是,我相信我可以排除与Java版本不兼容的情况,因为我也尝试在Java 9.0.4上运行此版本,并且也能够成功运行评分等级。

我的代码只是以下内容的许多实例,其后是VBox正常地包含它们,组以及场景和舞台-

        final RangeSlider blur = new RangeSlider(0,30,0,30);
        Text blurTitle = new Text("Blur");
        Text blurMin = new Text();
        blurMin.textProperty().bindBidirectional(blur.lowValueProperty(),converter);
        Text blurMax = new Text();
        blurMax.textProperty().bindBidirectional(blur.highValueProperty(),converter);
        HBox blurBox = new HBox();
        blurBox.getChildren().addAll(blurMin,blur,blurMax);
        blurBox.setPadding(new Insets(5));
        blurBox.setSpacing(10);

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

他们的位桶页面上已经有一个错误报告。看来它与java9 +不兼容

https://bitbucket.org/controlsfx/controlsfx/issues/802/rangeslider-uses-inaccessable-package

我没有阅读此特定控件的代码,但是您可以复制所需的代码并删除使用InputMap相关类的部分。

除此之外,最好将其降级为java8或使用另一个ui元素来模仿类似行为。

答案 1 :(得分:0)

在运行应用程序时在虚拟机参数中添加--add-exports=javafx.controls/com.sun.javafx.scene.control.inputmap=ALL-UNNAMED将解决此问题。感谢@kleopatra