- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在创建一个 JavaFX 应用程序。我可以启动应用程序并登录,但是当我尝试访问客户场景时,出现以下错误:
(提前对所有代码和错误表示歉意;不想遗漏任何内容)
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
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.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8411)
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.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:432)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Caused by: 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:498)
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:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
... 48 more
Caused by: javafx.fxml.LoadException: Error resolving onAction='#deleteCustomerButtonPushed', either the event handler is not in the Namespace or there is an error in the script.
file:/C:/Users/limpFish/Documents/repositories/c195-java-2/C195/dist/run642260308/C195.jar!/c195/CustomersScene.fxml:27
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:610)
at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770)
at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at c195.MainSceneController.customersButtonPushed(MainSceneController.java:43)
... 58 more
这是 CustomersScene.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane id="AnchorPane" prefHeight="591.0" prefWidth="475.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="c195.CustomersSceneController">
<children>
<VBox layoutY="51.0" prefHeight="541.0" prefWidth="500.0">
<children>
<TableView fx:id="customerTableView" prefHeight="470.0" prefWidth="500.0">
<columns>
<TableColumn fx:id="customerTableNameTableColumn" prefWidth="75.0" text="Name" />
<TableColumn fx:id="customerTableAddressTableColumn" prefWidth="302.0" text="Address" />
<TableColumn fx:id="customerTablePhoneNumberTableColumn" minWidth="0.0" prefWidth="122.0" text="Phone Number" />
</columns>
</TableView>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="100.0">
<children>
<Button fx:id="addCustomerButton" mnemonicParsing="false" onAction="#addCustomerButtonPushed" prefHeight="30.0" prefWidth="60.0" text="Add" />
<Button fx:id="modifyCustomerButton" mnemonicParsing="false" onAction="#modifyCustomerButtonPushed" prefHeight="30.0" prefWidth="60.0" text="Modify" />
<Button fx:id="deleteCustomerButton" mnemonicParsing="false" onAction="#deleteCustomerButtonPushed" prefHeight="30.0" prefWidth="60.0" text="Delete" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="260.0">
<children>
<Button fx:id="returnButton" mnemonicParsing="false" onAction="#returnButtonPushed" prefHeight="30.0" prefWidth="60.0" text="Return" />
<Button fx:id="quitButton" mnemonicParsing="false" onAction="#quitButtonPushed" prefHeight="30.0" prefWidth="60.0" text="Quit" />
</children>
</HBox>
</children>
</VBox>
<Label layoutX="19.0" layoutY="14.0" prefHeight="30.0" prefWidth="91.0" text="Customers">
<font>
<Font size="18.0" />
</font>
</Label>
</children>
</AnchorPane>
下面是我的 Controller 类(正在进行中):
package c195;
import java.io.IOException;
import java.net.URL;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
public class CustomersSceneController implements Initializable {
@FXML private TableView<Customer> customerTableView;
@FXML private TableColumn<Customer, String> customerTableNameTableColumn;
@FXML private TableColumn<Customer, String> customerTableAddressTableColumn;
@FXML private TableColumn<Customer, String> customerTablePhoneNumberTableColumn;
@FXML private Button addCustomerButton;
@FXML private Button modifyCustomerButton;
@FXML private Button deleteCustomerButton;
@FXML private Button returnButton;
@FXML private Button quitButton;
@FXML private void addCustomerButtonPushed(ActionEvent event) throws IOException
{
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("AddCustomerScene.fxml"));
Parent addCustomerSceneParent = loader.load();
Scene addCustomerSceneScene = new Scene(addCustomerSceneParent);
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow();
window.setScene(addCustomerSceneScene);
window.show();
}
@FXML private void modifyCustomerButtonPushed(ActionEvent event) throws IOException
{
// to do
}
@FXML private void deleteCustomerButtonPushed(Customer customer) throws SQLException
{
try
{
PreparedStatement sql = DatabaseUtils.getDBConnection().prepareStatement("Delete customer.*, address.* from customer inner join address on customer.addressId = address.addressId where customer.customerId = ?");
sql.setString(1, Integer.toString(customer.getCustomerId()));
sql.executeUpdate();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
@FXML private void returnButtonPushed(ActionEvent event) throws IOException
{
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("MainScene.fxml"));
Parent mainSceneParent = loader.load();
Scene mainSceneScene = new Scene(mainSceneParent);
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow();
window.setScene(mainSceneScene);
window.show();
}
@FXML private void quitButtonPushed(ActionEvent event) throws IOException
{
Alert alert = new Alert(Alert.AlertType.CONFIRMATION,
"Are you sure you want to quit?",
ButtonType.YES,
ButtonType.NO,
ButtonType.CANCEL);
alert.setHeaderText("Quit Confirmation");
alert.showAndWait()
.filter(response -> response == ButtonType.YES)
.ifPresent(response -> {
Platform.exit();
System.exit(0);
});
}
public ObservableList<Customer> updateCustomerTableView() throws SQLException
{
String customerId;
String name;
String address;
String address2;
String city;
String country;
String postalCode;
String totalAddress;
String phone;
ObservableList<Customer> customers = FXCollections.observableArrayList();
try
{
PreparedStatement sql = DatabaseUtils.getDBConnection().prepareStatement("Select customer.customerId, customer.customerName, address.address, address.address2, address.phone, city.city, country.country" +
"from customer" +
"inner join address on customer.addressId = address.addressId" +
"inner join city on address.cityId = city.cityId" +
"inner join country on city.countryId = country.countryId;");
ResultSet result = sql.executeQuery();
while (result.next())
{
customerId = result.getString("customer.customerId");
name = result.getString("custumer.customerName");
address = result.getString("address.address");
address2 = result.getString("address.address2");
city = result.getString("city.city");
country = result.getString("country.country");
postalCode = result.getString("address.postalCode");
phone = result.getString("address.phone");
Customer customer = new Customer(Integer.parseInt(customerId),
name,
address,
address2,
city,
country,
postalCode,
phone);
customers.add(customer);
}
}
catch (SQLException e)
{
e.printStackTrace();
}
return customers;
}
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
customerTableNameTableColumn.setCellValueFactory(new PropertyValueFactory<Customer, String>("name"));
customerTableAddressTableColumn.setCellValueFactory(new PropertyValueFactory<Customer, String>("totalAddress"));
customerTablePhoneNumberTableColumn.setCellValueFactory(new PropertyValueFactory<Customer, String>("phone"));
try {
updateCustomerTableView();
} catch (SQLException ex) {
Logger.getLogger(CustomersSceneController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
错误表明它找不到事件处理程序。我不知道为什么,因为我已将 @FXML 附加到该函数。我还尝试将函数公开(fxml 文档仍然建议这两个函数,该文档在第 27 行显示错误 -> #deleteCustomerButtonPushed)我已经检查了所有导入语句以确保使用 JavaFX 版本。
最佳答案
您得到的 InvocabularyTargetException 意味着系统正在尝试查找特定方法,但无法找到合适的候选方法。正如错误所示:“事件处理程序不在命名空间中”。
问题来自于你的方法的签名:
@FXML private void deleteCustomerButtonPushed(Customer customer) {
//...
}
参数应该是像其他方法一样的 ActionEvent
,而不是 Customer
。
@FXML private void deleteCustomerButtonPushed(ActionEvent e) {
//...
}
关于JavaFX错误: Event Handler is not in the namespace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57983511/
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码: from PIL import Image from pytesseract import image_
我的错误 /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference
我已经训练了一个模型,我正在尝试使用 predict函数但它返回以下错误。 Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]])
根据Microsoft DataConnectors的信息我想通过 this ODBC driver 创建一个从 PowerBi 到 PostgreSQL 的连接器使用直接查询。我重用了 Micros
我已经为 SoundManagement 创建了一个包,其中有一个扩展 MediaPlayer 的类。我希望全局控制这个变量。这是我的代码: package soundmanagement; impo
我在Heroku上部署了一个应用程序。我正在使用免费服务。 我经常收到以下错误消息。 PG::Error: ERROR: out of memory 如果刷新浏览器,就可以了。但是随后,它又随机发生
我正在运行 LAMP 服务器,这个 .htaccess 给我一个 500 错误。其作用是过滤关键字并重定向到相应的域名。 Options +FollowSymLinks RewriteEngine
我有两个驱动器 A 和 B。使用 python 脚本,我在“A”驱动器中创建一些文件,并运行 powerscript,该脚本以 1 秒的间隔将驱动器 A 中的所有文件复制到驱动器 B。 我在 powe
下面的函数一直返回这个错误信息。我认为可能是 double_precision 字段类型导致了这种情况,我尝试使用 CAST,但要么不是这样,要么我没有做对...帮助? 这是错误: ERROR: i
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
我的数据库有这个小问题。 我创建了一个表“articoli”,其中包含商品的品牌、型号和价格。 每篇文章都由一个 id (ID_ARTICOLO)` 定义,它是一个自动递增字段。 好吧,现在当我尝试插
我是新来的。我目前正在 DeVry 在线学习中级 C++ 编程。我们正在使用 C++ Primer Plus 这本书,到目前为止我一直做得很好。我的老师最近向我们扔了一个曲线球。我目前的任务是这样的:
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的网站中有一段代码有问题;此错误仅发生在 Internet Explorer 7 中。 我没有在这里发布我所有的 HTML/CSS 标记,而是发布了网站的一个版本 here . 如您所见,我在列中有
如果尝试在 USB 设备上构建 node.js 应用程序时在我的树莓派上使用 npm 时遇到一些问题。 package.json 看起来像这样: { "name" : "node-todo",
在 Python 中,您有 None单例,在某些情况下表现得很奇怪: >>> a = None >>> type(a) >>> isinstance(a,None) Traceback (most
这是我的 build.gradle (Module:app) 文件: apply plugin: 'com.android.application' android { compileSdkV
我是 android 的新手,我的项目刚才编译和运行正常,但在我尝试实现抽屉导航后,它给了我这个错误 FAILURE: Build failed with an exception. What wen
谁能解释一下?我想我正在做一些非常愚蠢的事情,并且急切地等待着启蒙。 我得到这个输出: phpversion() == 7.2.25-1+0~20191128.32+debian8~1.gbp108
我是一名优秀的程序员,十分优秀!