Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4115568

Method DefaultTableModel.setDataVector(Vector,Vector) doesn't throw Exception.

XMLWordPrintable

    • sparc
    • solaris_2.5.1



      Name: aaC67449 Date: 02/26/98



       Methods DefaultTableModel.setDataVector(Vector newData,Vector columnIds) and setDataVector(Object[][] newData, Object[] columnIds) doesn't throw IllegalArgumentException, when the number of columns in newData does not equal the number of the column identifiers in columnIds.

      Javadoc says:"

          Throws:
              IllegalArgumentException - if newData is null or if the number of columns in newData does not equal the number of the column identifiers in columnIds."

      -------------------Example-----------------------------------
      import java.util.*;
      import java.awt.swing.table.*;
      public class Test {

         public static void main(String argv[]) {
        
             DefaultTableModel c = new DefaultTableModel();
             Vector idVector=new Vector();
             Vector dataVector=new Vector();
        
              //prepare data vector
             Vector elem=new Vector();
             for (int j=0;j<5;j++)
                elem.addElement(new Object());
             dataVector.addElement(elem);

             // test
            try {
               c.setDataVector(dataVector,idVector);
               System.out.println("Failed. IllegalArgumentException was not thrown.");
            } catch(IllegalArgumentException e) {
                   System.out.println("OKAY");
            }
        }
      }
      -------------------Output------------------------------------
      Failed. IllegalArgumentException was not thrown.

      ======================================================================

            erapinsunw Eric Rapin (Inactive)
            aalievsunw Artem Aliev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: