0

I Had an Error in Clear the JTable Content using JButton . Here is my Code .

private void ClearCartBTActionPerformed(java.awt.event.ActionEvent evt) {

   try{
       DefaultTableModel model = (DefaultTableModel)Cart_table.getModel();  //Cart_table (Var Name of Jtable)

       while(model.getRowCount()>0){
           for(int i= 0 ; i <model.getRowCount();i++){
               model.removeRow(i);
           }
       }

   }catch(Exception e){
       JOptionPane.showMessageDialog(null, e);
   }

}

Only I had an Error in model.removeRow(i);

What should I do ?

akash
  • 22,664
  • 11
  • 59
  • 87

0 Answers0