首页上一页 1 下一页尾页 2 条记录 1/1页
《java项目开发全程实录》图书管理系统运行图书信息修改功能时报错
发表在Java图书答疑
2009-05-14
是否精华
是
否
版块置顶:
是
否
报错内容为
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to com.wsy.JComPz.Item
at com.wsy.iframe.BookModiAndDelIFrame$addBookActionListener.actionPerformed(BookModiAndDelIFrame.java:322)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
错位位置为[font color=#FF0000]String ISBNs=ISBN.getText().trim();
[/font]
//分类
Object selectedItem = bookTypeModel.getSelectedItem();
if (selectedItem == null)
return;
Item item = (Item)selectedItem;
String bookTypes=item.getId();
System.out.println(bookTypes);
String translators=translator.getText().trim();
String bookNames=bookName.getText().trim();
String writers=writer.getText().trim();
String publishers=publisher.getText().trim();
String pubDates=pubDate.getText().trim();
String prices=price.getText().trim();
int i=Dao.Updatebook(ISBNs, bookTypes, bookNames, writers, translators, publishers, Date.valueOf(pubDates), Double.parseDouble(prices));
System.out.println(i);
if(i==1){
JOptionPane.showMessageDialog(null, "修改成功");
Object[][] results=getFileStates(Dao.selectBookInfo());
//注释代码为使用表格模型
DefaultTableModel model=new DefaultTableModel();
// DefaultTableModel model = (DefaultTableModel) table.getModel();
table.setModel(model);
model.setDataVector(results, columnNames);
}
}
}
class NumberListener extends KeyAdapter {
public void keyTyped(KeyEvent e) {
String numStr="0123456789."+(char)8;
if(numStr.indexOf(e.getKeyChar())<0){
e.consume();
}
}
}
}
错误是不是说不能将com.wsy.JComPz.Item转换成String类
要改怎么改?
我代码不怎么会
不知道改什么地方,怎么改
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to com.wsy.JComPz.Item
at com.wsy.iframe.BookModiAndDelIFrame$addBookActionListener.actionPerformed(BookModiAndDelIFrame.java:322)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
错位位置为[font color=#FF0000]String ISBNs=ISBN.getText().trim();
[/font]
//分类
Object selectedItem = bookTypeModel.getSelectedItem();
if (selectedItem == null)
return;
Item item = (Item)selectedItem;
String bookTypes=item.getId();
System.out.println(bookTypes);
String translators=translator.getText().trim();
String bookNames=bookName.getText().trim();
String writers=writer.getText().trim();
String publishers=publisher.getText().trim();
String pubDates=pubDate.getText().trim();
String prices=price.getText().trim();
int i=Dao.Updatebook(ISBNs, bookTypes, bookNames, writers, translators, publishers, Date.valueOf(pubDates), Double.parseDouble(prices));
System.out.println(i);
if(i==1){
JOptionPane.showMessageDialog(null, "修改成功");
Object[][] results=getFileStates(Dao.selectBookInfo());
//注释代码为使用表格模型
DefaultTableModel model=new DefaultTableModel();
// DefaultTableModel model = (DefaultTableModel) table.getModel();
table.setModel(model);
model.setDataVector(results, columnNames);
}
}
}
class NumberListener extends KeyAdapter {
public void keyTyped(KeyEvent e) {
String numStr="0123456789."+(char)8;
if(numStr.indexOf(e.getKeyChar())<0){
e.consume();
}
}
}
}
错误是不是说不能将com.wsy.JComPz.Item转换成String类
要改怎么改?
我代码不怎么会
不知道改什么地方,怎么改