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

java.awt.swing.JTable(int, int) does not work properly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.2.0
    • Fix Version/s: 1.0.2
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.0.2
    • CPU:
      sparc
    • OS:
      solaris_2.5, solaris_2.5.1

      Description



      Name: asC58863 Date: 02/18/98


      java.awt.swing.JTable.JTable(int columns, int rows) does not work as
      specified in the JavaDoc.

      (See JavaDoc comments)
      "public JTable(int numColumns,
                    int numRows)

            Constructs a JTable with numColumns and numRows of empty cells using
            the DefaultTableModel. The columns will
            have names of the form "A", "B", "C", etc.
            Parameters:
                  numColumns - The number of columns the table holds
                  numRows - The number of rows the table holds
      "
      In fact this ctor does not work as specified.

      Here is the example demonstrating the bug:
      ------------------ Test.java -----------------
      import java.awt.swing.*;
      import java.awt.swing.table.*;

      class Test {
        public static void main(String[] argv) {
         try {
          int col = 3, row = 1;
          System.out.println(" create object : new JTable("+col+","+row+");");
          
          JTable table = new JTable(col, row);
          
          System.out.println(" number of columns is "+table.getModel().getColumnCount()+" but should be "+col);
          System.out.println(" number of rows is "+table.getModel().getRowCount()+" but should be "+row);
          
          for(int i=0;i<table.getModel().getColumnCount();i++)
            System.out.println("Name of the "+i+" column : "+table.getModel().getColumnName(i));
            
         } catch(Exception e) {
           System.out.println(e+" has been thrown");
         }
         System.exit(0);
        }
      }

      -------------- Output from the test -----------------
      :\>java Test
       create object : new JTable(3,1);
        number of columns is 0 but should be 3
        number of rows is 1 but should be 1
      ------------------------------------------------------


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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              erapinsunw Eric Rapin (Inactive)
              Reporter:
              asemidetsunw Alexei Semidetnov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: