我已经在互联网的最深处进行了搜索,但似乎找不到答案-.-
问题出在我要编写的 javaFx 程序中。但除了添加 Controller 类之外,我无法做任何进一步的事情。我几乎遵循了所有可以找到的教程,但我仍然不知道这个问题。
这是异常(exception)情况:
javafx.fxml.LoadException:
/U:/BankingSolutions/MediaCenterFX/bin/main/ressources/view/MainUI.fxml:12
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2617)
at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:104)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:927)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:976)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:738)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2723)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3230)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3191)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3164)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3140)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3120)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3113)
at application.Main.start(Main.java:15)
at com.sun.javafx.application.LauncherImpl$8.run(LauncherImpl.java:837)
at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
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)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: /java/controllers/MainUIController
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:925)
... 24 more
这是代码。有三个类:Main.class,我使用 scenebuilder 2 创建的 MainUI.fxml 和我的 MainUIController.class,它显然应该作为 mainuis Controller 工作
package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
AnchorPane root = (AnchorPane) FXMLLoader.load(getClass().getResource("/main/ressources/view/MainUI.fxml"));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
_______________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.image.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane fx:id="root" prefHeight="1080.0" prefWidth="1920.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="/java/controllers/MainUIController">
<children>
<BorderPane fx:id="borderPane01" layoutX="657.0" layoutY="304.0" prefHeight="336.0" prefWidth="403.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<bottom>
<AnchorPane fx:id="bp_bottom" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
</bottom>
<left>
<GridPane fx:id="bp_left_grid" prefHeight="680.0" prefWidth="238.0" BorderPane.alignment="CENTER">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Button fx:id="btn_search" mnemonicParsing="false" prefHeight="48.0" prefWidth="172.0" text="Suche" GridPane.columnSpan="2147483647" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.valignment="CENTER">
<GridPane.margin>
<Insets />
</GridPane.margin>
<font>
<Font size="24.0" />
</font>
</Button>
<Button fx:id="btn_series" mnemonicParsing="false" prefHeight="48.0" prefWidth="172.0" text="Serien" wrapText="true" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
<font>
<Font size="24.0" />
</font>
</Button>
<Button fx:id="btn_download" mnemonicParsing="false" prefHeight="48.0" prefWidth="172.0" text="Download" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER">
<font>
<Font size="24.0" />
</font>
</Button>
<Button fx:id="btn_movies" mnemonicParsing="false" prefHeight="48.0" prefWidth="172.0" text="Filme" wrapText="true" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER">
<font>
<Font size="24.0" />
</font>
</Button>
<Button fx:id="btn_exit" mnemonicParsing="false" prefHeight="48.0" prefWidth="172.0" text="Beenden" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="6" GridPane.valignment="CENTER">
<font>
<Font size="24.0" />
</font>
</Button>
<Button fx:id="btn_settings" mnemonicParsing="false" prefHeight="48.0" prefWidth="172.0" text="Optionen" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="4" GridPane.valignment="CENTER">
<font>
<Font size="24.0" />
</font>
</Button>
<Button fx:id="btn_dashboard" mnemonicParsing="false" prefHeight="48.0" prefWidth="172.0" text="Dashboard" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="5" GridPane.valignment="CENTER">
<font>
<Font size="24.0" />
</font>
</Button>
</children>
</GridPane>
</left>
<top>
<AnchorPane fx:id="bp_top" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<Label fx:id="headlabel" alignment="CENTER" layoutX="737.0" layoutY="92.0" prefHeight="200.0" prefWidth="1920.0" text="Dashboard" textAlignment="CENTER" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font size="48.0" />
</font>
</Label>
</children>
</AnchorPane>
</top>
<center>
<AnchorPane fx:id="bp_center" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
</center>
<right>
<AnchorPane fx:id="bp_right" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
</right>
</BorderPane>
</children>
</AnchorPane>
______________________________________________
package main.java.controllers;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
public class MainUIController{
@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;
@FXML // fx:id="btn_search"
private Button btn_search; // Value injected by FXMLLoader
@FXML // fx:id="btn_movies"
private Button btn_movies; // Value injected by FXMLLoader
@FXML // fx:id="btn_exit"
private Button btn_exit; // Value injected by FXMLLoader
@FXML // fx:id="btn_series"
private Button btn_series; // Value injected by FXMLLoader
@FXML // fx:id="bp_right"
private AnchorPane bp_right; // Value injected by FXMLLoader
@FXML // fx:id="bp_bottom"
private AnchorPane bp_bottom; // Value injected by FXMLLoader
@FXML // fx:id="borderPane01"
private BorderPane borderPane01; // Value injected by FXMLLoader
@FXML // fx:id="headlabel"
private Label headlabel; // Value injected by FXMLLoader
@FXML // fx:id="bp_left_grid"
private GridPane bp_left_grid; // Value injected by FXMLLoader
@FXML // fx:id="bp_top"
private AnchorPane bp_top; // Value injected by FXMLLoader
@FXML // fx:id="root"
private AnchorPane root; // Value injected by FXMLLoader
@FXML // fx:id="btn_download"
private Button btn_download; // Value injected by FXMLLoader
@FXML // fx:id="btn_dashboard
private Button btn_dashboard; // Value injected by FXMLLoader
@FXML // fx:id="bp_center"
private AnchorPane bp_center; // Value injected by FXMLLoader
@FXML // fx:id="btn_settings"
private Button btn_settings; // Value injected by FXMLLoader
@FXML // This method is called by the FXMLLoader when initialization is complete
void initialize() {
assert root != null : "fx:id=\"root\" was not injected: check your FXML file 'MainUI.fxml'.";
assert borderPane01 != null : "fx:id=\"borderPane01\" was not injected: check your FXML file 'MainUI.fxml'.";
assert bp_top != null : "fx:id=\"bp_top\" was not injected: check your FXML file 'MainUI.fxml'.";
assert headlabel != null : "fx:id=\"headlabel\" was not injected: check your FXML file 'MainUI.fxml'.";
assert bp_left_grid != null : "fx:id=\"bp_left_grid\" was not injected: check your FXML file 'MainUI.fxml'.";
assert bp_center != null : "fx:id=\"bp_center\" was not injected: check your FXML file 'MainUI.fxml'.";
assert bp_right != null : "fx:id=\"bp_right\" was not injected: check your FXML file 'MainUI.fxml'.";
assert bp_bottom != null : "fx:id=\"bp_bottom\" was not injected: check your FXML file 'MainUI.fxml'.";
assert btn_search != null : "fx:id=\"btn_search\" was not injected: check your FXML file 'MainUI.fxml'.";
assert btn_series != null : "fx:id=\"btn_series\" was not injected: check your FXML file 'MainUI.fxml'.";
assert btn_movies != null : "fx:id=\"btn_movies\" was not injected: check your FXML file 'MainUI.fxml'.";
assert btn_download != null : "fx:id=\"btn_download\" was not injected: check your FXML file 'MainUI.fxml'.";
assert btn_settings != null : "fx:id=\"btn_settings\" was not injected: check your FXML file 'MainUI.fxml'.";
assert btn_dashboard!= null : "fx:id=\"dashboard\" was not injected: check your FXML file 'MainUI.fxml'.";
assert btn_exit != null : "fx:id=\"btn_exit\" was not injected: check your FXML file 'MainUI.fxml'.";
btn_search.setOnAction(value -> {
System.out.println("Search pressed"); //TODO
});
btn_series.setOnAction(value ->{
System.out.println("series pressed");
});
btn_movies.setOnAction(value ->{
System.out.println("movies pressed");
});
btn_download.setOnAction(value ->{
System.out.println("download pressed");
});
btn_settings.setOnAction(value ->{
System.out.println("settings pressed");
});
btn_dashboard.setOnAction(value ->{
System.out.println("dashboard pressed");
});
btn_exit.setOnAction(value ->{
System.out.println("exit pressed");
});
}
}
编辑:这是我的包结构:
src
|-application
|here is my main application
|-main
|-java
|-controllers
|here are my controllers
|-dao
|-service
|-ressources
|-css
|-images
|-view
|here are the fxml files
最佳答案
fx:controller 属性需要 Controller 类的完全限定类名。 IE。假设你有
package main.java.controllers ;
public class MainUIController { ... }
你应该有
fx:controller="main.java.controllers.MainUIController"
关于java - 尝试运行 javafx 应用程序时出现 "FXMLLoader.constructLoadException",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31135192/
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
我构建了两个需要相互通信和发送文件的Rails应用程序。例如,一个Rails应用程序会发送请求以查看其他应用程序数据库中的表。然后另一个应用程序将呈现该表的json并将其发回。我还希望一个应用程序将存储在其公共(public)目录中的文本文件发送到另一个应用程序的公共(public)目录。我从来没有做过这样的事情,所以我什至不知道从哪里开始。任何帮助,将不胜感激。谢谢! 最佳答案 无论Rails是什么,几乎所有Web应用程序都有您的要求,大多数现代Web应用程序都需要相互通信。但是有一个小小的理解需要你坚持下去,网站不应直接访问彼此
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r