如何使用 JavaFX 和 scenebulider 配置 IntelliJ IDEA?
Posted
技术标签:
【中文标题】如何使用 JavaFX 和 scenebulider 配置 IntelliJ IDEA?【英文标题】:How do I configure IntelliJ IDEA with JavaFX and scenebulider? 【发布时间】:2015-04-21 08:36:05 【问题描述】:我正在尝试使用 screenbuilder 和 JavaFX 和 scenebuilder 设置 IntelliJ IDEA。我都安装了,但是当我创建一个新的 JavaFX 项目,打开 fxml 文件并切换到 scenebuilder 选项卡时,我收到一个很长的错误消息来代替 scenebuilder UI:
java.lang.reflect.InvocationTargetException
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 org.jetbrains.plugins.javaFX.sceneBuilder.SceneBuilderCreatorImpl.create(SceneBuilderCreatorImpl.java:35)
at org.jetbrains.plugins.javaFX.sceneBuilder.SceneBuilderEditor.addSceneBuilder(SceneBuilderEditor.java:204)
at org.jetbrains.plugins.javaFX.sceneBuilder.SceneBuilderEditor.access$700(SceneBuilderEditor.java:34)
at org.jetbrains.plugins.javaFX.sceneBuilder.SceneBuilderEditor$ExternalChangeListener.checkContent(SceneBuilderEditor.java:338)
at org.jetbrains.plugins.javaFX.sceneBuilder.SceneBuilderEditor.initSceneBuilder(SceneBuilderEditor.java:180)
at org.jetbrains.plugins.javaFX.sceneBuilder.SceneBuilderEditor.selectNotify(SceneBuilderEditor.java:252)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$10.run(FileEditorManagerImpl.java:875)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:702)
at java.awt.EventQueue$3.run(EventQueue.java:696)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:748)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:577)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:384)
at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:832)
at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:208)
at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:660)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:418)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:413)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:366)
at com.intellij.openapi.project.impl.ProjectManagerImpl.openProject(ProjectManagerImpl.java:456)
at com.intellij.openapi.project.impl.ProjectManagerImpl.loadAndOpenProject(ProjectManagerImpl.java:544)
at com.intellij.ide.impl.ProjectUtil.openProject(ProjectUtil.java:181)
at com.intellij.ide.RecentProjectsManager.doOpenProject(RecentProjectsManager.java:46)
at com.intellij.ide.RecentProjectsManagerBase.doReopenLastProject(RecentProjectsManagerBase.java:340)
at com.intellij.ide.RecentProjectsManagerBase$MyAppLifecycleListener.appStarting(RecentProjectsManagerBase.java:367)
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 com.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:114)
at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:315)
at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:302)
at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:287)
at com.intellij.util.messages.impl.MessageBusImpl.access$200(MessageBusImpl.java:41)
at com.intellij.util.messages.impl.MessageBusImpl$2.invoke(MessageBusImpl.java:177)
at com.sun.proxy.$Proxy45.appStarting(Unknown Source)
at com.intellij.idea.IdeaApplication.loadProject(IdeaApplication.java:306)
at com.intellij.idea.IdeaApplication.access$500(IdeaApplication.java:55)
at com.intellij.idea.IdeaApplication$IdeStarter$2.run(IdeaApplication.java:280)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:318)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:702)
at java.awt.EventQueue$3.run(EventQueue.java:696)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:748)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:577)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:384)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NoClassDefFoundError: javafx/fxml/FXMLLoader
at org.jetbrains.plugins.javaFX.sceneBuilder.SceneBuilderKitWrapper.create(SceneBuilderKitWrapper.java:19)
... 66 more
我认为有些地方配置错误,但我不确定要检查什么。有人可以指出我正确的方向吗?
【问题讨论】:
请尝试删除并重新创建您在项目中使用的 JDK。 @yole 就像卸载并重新安装它,还是别的什么? 就像在“项目结构”对话框中删除 JDK 然后将其添加回来一样。 @yole 我也有同样的问题。 :-( 这里有同样的问题。删除 jdk 并重新添加它没有帮助 【参考方案1】:我遇到了同样的问题,在我的情况下是由 intellij 捆绑的 jdk 引起的。尝试将 ide 的 jdk 如 show here 切换到包含所有需要的类的 oracle jdk 8。
【讨论】:
IntelliJ Idea v15.0.2,切换到Oracle JDK 1.8.0_65 不解决 对我有帮助:Idea 15.0.2,Mac OS X 它也帮助了我。谢谢 只是为了澄清Tibi的正确答案:您需要切换IntelliJ运行的JDK,而不是项目SDK。这个目前在Help -> Find action -> Switch IDE boot JDK下。【参考方案2】:你必须添加文件idea.jdk ~/.IntelliJIdea2016.1/config 文件夹。
添加 Oracle JDK 路径,如 /usr/java/jdk1.8.0_73
【讨论】:
以上是关于如何使用 JavaFX 和 scenebulider 配置 IntelliJ IDEA?的主要内容,如果未能解决你的问题,请参考以下文章
如何限制图例大小并使其可使用饼图滚动?和 javafx 布局