日期:2014-05-20  浏览次数:20775 次

调用模式往table里插入数据受阻 救命
运行后错误如下: 
java.lang.ClassCastException: javax.swing.JTable$1 cannot be cast to javax.swing.table.DefaultTableModel at mhs.RSS.actionPerformed(RSS.java:90) 
  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) 
 
程序代码如下: 
import javax.swing.*; 
import javax.swing.event.*; 
import javax.swing.table.*; 
import java.util.*; 
import java.awt.*; 
import java.awt.event.*; 
 
import java.net.URL;  
import java.util.List;  
import java.util.*; 
import java.text.SimpleDateFormat; 
 
import com.sun.syndication.feed.synd.SyndCategory;  
import com.sun.syndication.feed.synd.SyndContent;  
import com.sun.syndication.feed.synd.SyndEnclosure;  
import com.sun.syndication.feed.synd.SyndEntry;  
import com.sun.syndication.feed.synd.SyndFeed;  
import com.sun.syndication.io.SyndFeedInput;  
import com.sun.syndication.io.XmlReader;  
 
 
public class RSS extends Frame implements ActionListener 

  JLabel RSS = new JLabel("RSS:"); 
  JTextField URL = new JTextField(); 
  JButton JB= new JButton("确认"); 
  Object[][]tablevalue = new Object[20][4]; 
  String []name={"标题","作者","时间","摘要"}; 
  JTable table = new JTable(tablevalue,name); 
   
  public RSS() 
  { 
  this.setTitle("欢迎使用RSS阅读器"); 
 
  RSS.setBounds(100,570,60,60); 
  this.add(RSS); 
  URL.setBounds(170,570,400,50); 
  this.add(URL); 
  JB.setBounds(620,570,70,50); 
  this.add(JB);