忙于学校项目,NetBeans 让我沮丧得要死。请帮我解决以下错误,并告诉我我做错了什么。
我正忙于绑定和 Apache Derby。我正在做的是将数据库中的数据绑定到文本字段。我有一个带有两个选项卡式面板的 JFrame 表单。一个有一个表1,另一个显示个人记录2。
这是单个记录视图上绑定的编码摘录:
1 package UserManager;
import java.util.*;
5 /**
*
* @author Johan Brink
*/
public class Data extends javax.swing.JFrame {
10 Users users = new Users();
ListIterator<Users>iterator;
public Users getUsers() {
return users;
15 }
public void setUsers(Users users) {
Users oldUsers = this.users;
this.users = users;
20 firePropertyChange("users", oldUsers, users);
}
/**
* Creates new form Data
25 */
public Data() {
initComponents();
setLocationRelativeTo(rootPane);
iterator = usersList.listIterator(0);
30 setUsers(iterator.next());
}
问题出在第 29 行和第 30 行。这在过去有效,但现在出现错误。我有一个自动创建的实体类等。没有第 29 行和第 30 行,除了未列出个人记录信息外,一切正常。插入第 29 行和第 30 行时,运行时显示如下错误:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: Cannot cast java.util.Date to java.lang.String
at java.lang.Class.cast(Class.java:3084)
at org.jdesktop.beansbinding.Binding.convertForward(Binding.java:1312)
at org.jdesktop.beansbinding.Binding.getSourceValueForTarget(Binding.java:844)
at org.jdesktop.beansbinding.Binding.refreshUnmanaged(Binding.java:1222)
at org.jdesktop.beansbinding.Binding.refresh(Binding.java:1207)
at org.jdesktop.beansbinding.AutoBinding.tryRefreshThenSave(AutoBinding.java:162)
at org.jdesktop.beansbinding.AutoBinding.sourceChangedImpl(AutoBinding.java:227)
at org.jdesktop.beansbinding.Binding.sourceChanged(Binding.java:1411)
at org.jdesktop.beansbinding.Binding.access$1200(Binding.java:38)
at org.jdesktop.beansbinding.Binding$PSL.propertyStateChanged(Binding.java:1618)
at org.jdesktop.beansbinding.PropertyHelper.firePropertyStateChange(PropertyHelper.java:212)
at org.jdesktop.beansbinding.ELProperty.notifyListeners(ELProperty.java:688)
at org.jdesktop.beansbinding.ELProperty.access$800(ELProperty.java:155)
at org.jdesktop.beansbinding.ELProperty$SourceEntry.processSourceChanged(ELProperty.java:312)
at org.jdesktop.beansbinding.ELProperty$SourceEntry.sourceChanged(ELProperty.java:326)
at org.jdesktop.beansbinding.ELProperty$SourceEntry.propertyChange(ELProperty.java:333)
at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
at java.awt.Component.firePropertyChange(Component.java:8382)
at UserManager.Data.setUsers(Data.java:24)
at UserManager.Data.<init>(Data.java:34)
at UserManager.Data$7.run(Data.java:419)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)