我在JavaFX中创建了一个程序和一个寄存器,它有两个日期和时间字段,在注册时填充。使用带有注释的Hibernate来做映射,当我提交日期和时间时,它会生成这个错误,并将保存:
java.lang.RuntimeException: java.lang.IllegalArgumentException
at br.upf.ads.daoo.global.action.AbstractAction.actionPerformed(AbstractAction.java:63)
at br.upf.ads.daoo.global.controller.AbstractController.handle(AbstractController.java:156)
at br.upf.ads.daoo.global.controller.AbstractController.handle(AbstractController.java:31)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Node.fireEvent(Node.java:6863)
at javafx.scene.control.Button.fire(Button.java:179)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3328)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3168)
at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3123)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1563)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2265)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:250)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:173)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:292)
at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
at com.sun.glass.ui.View.notifyMouse(View.java:922)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:722)
原因:java。lang.IllegalArgumentException
at java.util.Date.parse(Date.java:615)
at java.util.Date.<init>(Date.java:272)
at br.upf.ads.daoo.ui.CompraIncluirView.loadCompraFromPanel(CompraIncluirView.java:179)
at br.upf.ads.daoo.ui.CompraIncluirView.getCompra(CompraIncluirView.java:205)
at br.upf.ads.daoo.controller.CompraIncluirController$4.conditional(CompraIncluirController.java:58)
at br.upf.ads.daoo.global.action.ConditionalAction.action(ConditionalAction.java:51)
at br.upf.ads.daoo.global.action.AbstractAction.actionPerformed(AbstractAction.java:58)
... 50 more
可能是什么错误?下面是一些我认为是错误的代码:
private Compra loadCompraFromPanel() {
Integer id = null;
try {
id = Integer.parseInt(tfId.getText());
} catch (Exception nex) {
}
Date data = null;
if (!tfData.getText().trim().isEmpty()) {
data= new Date(tfData.getText());
}
Float valor = null;
try {
valor = Float.parseFloat(tfValor.getText());
} catch (Exception nex) {
}
Date horario = null;
if (!tfHorario.getText().trim().isEmpty()) {
horario = new Date(tfHorario.getText());
}
Passageiro passageiro = cbPassageiro.getValue();
Capital capital = cbCapital.getValue();
return new Compra(id, data, valor, horario, passageiro, capital);
}
您正在传递tfData,因此会收到一个
(一个字符串)作为IllegalArgumentException
。getText()数据的构造函数(这是一个
日期
):
data= new Date(tfData.getText());
类
Date
的构造函数是:
Date()
Date(int year, int month, int date) //Deprecated
Date(int year, int month, int date, int hrs, int min) //Deprecated
Date(int year, int month, int date, int hrs, int min, int sec) //Deprecated
Date(long date)
Date(String s) //Deprecated
显然
String
从tfData.getText()
返回的Date(String s)
(弃用)构造函数的格式无效。
之所以出现错误,是因为无法分析传递给新日期(字符串s)
的值(或者tfData.getText()
或者tfHorario)。getText()
)。但是,应该使用DateFormat
而不是不推荐使用的Date
构造函数。例如:
DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
Date horario = null;
try {
horario = df.parse(tfHorario.getText());
} catch (ParseException e) {
// The user didn't provide a string in the correct format, show an error or something
}
另请参见:SimpleDateFormat
我是的新手,我正在尝试使用在eclipse上构建一个应用程序,我遵循了一个教程,并且做了完全相同的操作,该应用程序非常简单,当我试图编译它时,我得到了一堆我甚至不理解的错误: 你能告诉我我错过了什么吗。
问题内容: 我有一个Swing应用程序,需要在其中显示内部生成的HTML / CSS。为了做到这一点,我改编了这个StackOverflow问题的代码。 该控件工作正常。但是,当应用程序结束时,我收到错误消息 就其价值而言,直接来自Oracle的示例代码(在StackOverflow帖子中引用)具有相同的问题。 我尝试过在窗口关闭时显式调用,但错误仍然存在。那么,当JavaFX嵌入到Swing
> 我开发了一个javaFx应用程序,并在Mac的com.zenjava maven插件的帮助下创建了该应用程序的中间包。 bundle是用JDK:1.7.0_40.jdk创建的
这是我第一次使用Javafx与Spring Boot我有以下错误时运行我的应用程序 主课 } 控制器类 } pom.xml http://maven.apache.org/xsd/maven-4.0.0.xsd" 拜托这是怎么回事。为什么org.springframework.boot:sping-boo-maven-plugin:2.0.0。释放:运行不能被执行? 场景fxml代码 我正在用Ne
本文向大家介绍javafx Hello World程序,包括了javafx Hello World程序的使用技巧和注意事项,需要的朋友参考一下 示例 以下代码创建了一个简单的用户界面,其中包含一个单击即可在控制台上Button打印一个的用户界面String。 该Application班是每一个JavaFX应用程序的入口点。只能Application启动一个,并且可以使用 这将创建Applicati
乍一看,这个问题似乎是重复的。我已经在谷歌搜索了一些,但不幸的是,没有一个结果不符合我。我给出了下面的问题链接。 应用程序启动方法java.lang.Reflect.InvocationTargetException JavaFX图像转换中出现异常 JavaFX-应用程序启动方法中的异常? 应用程序启动方法中出现异常 堆栈跟踪: 无法从此StackTrace跟踪错误。然后我在start方法中使用了