src/share/classes/javax/swing/JTable.java

Print this page




 652      * @see javax.swing.table.DefaultTableModel
 653      */
 654     public JTable(int numRows, int numColumns) {
 655         this(new DefaultTableModel(numRows, numColumns));
 656     }
 657 
 658     /**
 659      * Constructs a <code>JTable</code> to display the values in the
 660      * <code>Vector</code> of <code>Vectors</code>, <code>rowData</code>,
 661      * with column names, <code>columnNames</code>.  The
 662      * <code>Vectors</code> contained in <code>rowData</code>
 663      * should contain the values for that row. In other words,
 664      * the value of the cell at row 1, column 5 can be obtained
 665      * with the following code:
 666      *
 667      * <pre>((Vector)rowData.elementAt(1)).elementAt(5);</pre>
 668      *
 669      * @param rowData           the data for the new table
 670      * @param columnNames       names of each column
 671      */
 672     public JTable(Vector<Vector<Object>> rowData, Vector<Object> columnNames) {

 673         this(new DefaultTableModel(rowData, columnNames));
 674     }
 675 
 676     /**
 677      * Constructs a <code>JTable</code> to display the values in the two dimensional array,
 678      * <code>rowData</code>, with column names, <code>columnNames</code>.
 679      * <code>rowData</code> is an array of rows, so the value of the cell at row 1,
 680      * column 5 can be obtained with the following code:
 681      *
 682      * <pre> rowData[1][5]; </pre>
 683      * <p>
 684      * All rows must be of the same length as <code>columnNames</code>.
 685      *
 686      * @param rowData           the data for the new table
 687      * @param columnNames       names of each column
 688      */
 689     public JTable(final Object[][] rowData, final Object[] columnNames) {
 690         this(new AbstractTableModel() {
 691             public String getColumnName(int column) { return columnNames[column].toString(); }
 692             public int getRowCount() { return rowData.length; }




 652      * @see javax.swing.table.DefaultTableModel
 653      */
 654     public JTable(int numRows, int numColumns) {
 655         this(new DefaultTableModel(numRows, numColumns));
 656     }
 657 
 658     /**
 659      * Constructs a <code>JTable</code> to display the values in the
 660      * <code>Vector</code> of <code>Vectors</code>, <code>rowData</code>,
 661      * with column names, <code>columnNames</code>.  The
 662      * <code>Vectors</code> contained in <code>rowData</code>
 663      * should contain the values for that row. In other words,
 664      * the value of the cell at row 1, column 5 can be obtained
 665      * with the following code:
 666      *
 667      * <pre>((Vector)rowData.elementAt(1)).elementAt(5);</pre>
 668      *
 669      * @param rowData           the data for the new table
 670      * @param columnNames       names of each column
 671      */
 672     @SuppressWarnings("rawtypes")
 673     public JTable(Vector<Vector> rowData, Vector<?> columnNames) {
 674         this(new DefaultTableModel(rowData, columnNames));
 675     }
 676 
 677     /**
 678      * Constructs a <code>JTable</code> to display the values in the two dimensional array,
 679      * <code>rowData</code>, with column names, <code>columnNames</code>.
 680      * <code>rowData</code> is an array of rows, so the value of the cell at row 1,
 681      * column 5 can be obtained with the following code:
 682      *
 683      * <pre> rowData[1][5]; </pre>
 684      * <p>
 685      * All rows must be of the same length as <code>columnNames</code>.
 686      *
 687      * @param rowData           the data for the new table
 688      * @param columnNames       names of each column
 689      */
 690     public JTable(final Object[][] rowData, final Object[] columnNames) {
 691         this(new AbstractTableModel() {
 692             public String getColumnName(int column) { return columnNames[column].toString(); }
 693             public int getRowCount() { return rowData.length; }