-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.0.2
-
sparc
-
solaris_2.5, solaris_2.5.1
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
------------------------------------------------------
======================================================================
- duplicates
-
JDK-4115153 Constructor DefaultTableModel(int,int) does not set number of columns.
- Closed