我使用以下代码在我当前的项目中打开一个对话框,因为我已经阅读了有关controlfx及其令人敬畏的对话框,所以我在我的项目中使用了它的代码,但它给出了错误,我不知道为什么?
Dialogs.create()
.owner(SchoolManagement2.stage1)
.title("Information Dialog")
.masthead("Look, an Information Dialog")
.message("I have a great message for you!")
.showInformation();
我添加了以下jar
controlsfx-8.0.6_20.jar
controlsfx-samples-8.0.6_20.jar
fxsampler-1.0.6_20.jar
我收到以下错误:
java.lang.RuntimeException: ControlsFX Error: ControlsFX 8.0.6_20 requires at least Java 8u20
at impl.org.controlsfx.version.VersionChecker.doVersionCheck(VersionChecker.java:83)
at org.controlsfx.control.ControlsFXControl.<init>(ControlsFXControl.java:35)
at org.controlsfx.control.ButtonBar.<init>(ButtonBar.java:366)
at org.controlsfx.control.ButtonBar.<init>(ButtonBar.java:357)
at org.controlsfx.dialog.Dialog.createButtonPanel(Dialog.java:1034)
at org.controlsfx.dialog.Dialog.createCenterPanel(Dialog.java:1029)
at org.controlsfx.dialog.Dialog.buildDialogContent(Dialog.java:950)
at org.controlsfx.dialog.Dialog.show(Dialog.java:320)
at org.controlsfx.dialog.Dialogs.showSimpleContentDialog(Dialogs.java:1106)
at org.controlsfx.dialog.Dialogs.showInformation(Dialogs.java:531)
at schoolmanagement2.FeesdepositeController.show(FeesdepositeController.java:633)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1763)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1651)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:204)
at javafx.scene.Node.fireEvent(Node.java:8175)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:204)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3746)
at javafx.scene.Scene$MouseHandler.access$1800(Scene.java:3471)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1695)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2486)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:314)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:243)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:345)
at com.sun.glass.ui.View.handleMouseEvent(View.java:526)
at com.sun.glass.ui.View.notifyMouse(View.java:898)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
错误显示为ControlsFX Error: ControlsFX 8.0.6_20 requires at least Java 8u20
,因此我安装了jdk-8u20-ea-bin-b22-windows-x64-08_jul_2014.exe
,但错误仍然相同。
请帮帮我。
答案 0 :(得分:1)
嘿,我警告了,我想要的东西
警报=新警报(AlertType.WARNING);
alert.setTitle("Warning");
alert.setHeaderText("Look, a Warning Dialog");
alert.setContentText("your content text!");
alert.showAndWait();
您不必nedd添加controlfx.jar,javaFx已经准备好将其导入
答案 1 :(得分:0)
我正在使用Netbeans和Mac OS ML。
我有同样的问题,我无法从Netbeans运行我的程序。但是如果我用Netbeans运行.jar文件,这样可以正常工作:)
我看到在Netbeans中设置的JRE为1.8.11,我无法将JRE 1.8.20安装到我的机器中。
编辑: 我在我的cas中解决了这个问题:编辑Netbeans配置文件
- 在Mac OS X上:在Finder中按住Ctrl键并单击/ Applications / NetBeans / NetBeans IDE 6.5.app,然后选择显示包内容&#39;,然后浏览到/ Applications / NetBeans / NetBeans \ IDE \ 6.5 。应用程序/内容/资源/的NetBeans的/ etc /的netbeans.conf。
- 在Windows上:C:\ Program Files \ Netbeans \ etc \ netbeans.conf
- 在Linux上,安装程序允许用户选择要安装NetBeans的位置。您可以在/home/yourname/netbeans/etc/netbeans.conf或/opt/netbeans/etc/netbeans.conf下找到它。
请参阅:http://wiki.netbeans.org/FaqNetbeansConf
我们需要在此行中用 jdk1.8.0_20 替换当前的jdk: netbeans_jdkhome =&#34; /库/爪哇/ JavaVirtualMachines /的 jdk1.8.0_11 强> .jdk /内容/主页&#34;
为了安全起见,执行此操作后,请复制netbeans.conf文件:)