for(int j=table.getRowCount()-1;j>=0;j-- )
  ((DefaultTableModel)table.getModel()).removeRow(j);

解决方案 »

  1.   


    谢谢 很奇怪运行时说超界了 
    我想是不是有所误会, 我的意思是把所有的内容设成空  不是减少row 数或column数
      

  2.   


    是不是没有专门的方法?我就借用geyf的循环这么做了   :(for(int j=table.getRowCount()-1;j>=0;j-- )
     for(int i=table.getColumnCount()-1; i>=0; i--)
      table.setValueAt("",j,i);
      

  3.   

    你可以这样做
    JTable table;   
    Vector columnHeads ;//列头的信息
    ...table.setModel(new DefaultTableModel(columnHeads,table.getRowCount()));这个可能比直接赋值自然些吧