Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    [JAVA]-Errore Costruttore JTable

    Qualcuno mi sa dire dove č l'errore?

    ArrayList array = new ArrayList();
    while (rs.next()) {
    String[] row = {rs.getString(1), rs.getString(2), rs.getString(3)};
    array.add(row);
    }
    ResultSetMetaData rsmd = rs.getMetaData();
    String[] cols = new String[rsmd.getColumnCount()];
    for (int i=0; i<cols.length; i++) {
    cols[i] = rsmd.getColumnName(i + 1);
    }
    JTable table = new JTable(array.toArray(), cols); //ERRORE
    JScrollPane cptable = new JScrollPane(table);
    contentPane.add (cptable,BorderLayout.SOUTH);
    repaint();

    L'errore č: Non riesce a risolvere questo simbolo.
    symbol : constructor JTable (java.lang.Object[],java.lang.String[])
    location: class javax.swing.JTable

    Ciao, amici

  2. #2
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    328
    Costruttori di JTable:

    codice:
    JTable() 
              Constructs a default JTable that is initialized with a default data model, a default column model, and a default selection model. 
    JTable(int numRows, int numColumns) 
              Constructs a JTable with numRows and numColumns of empty cells using DefaultTableModel. 
    JTable(Object[][] rowData, Object[] columnNames) 
              Constructs a JTable to display the values in the two dimensional array, rowData, with column names, columnNames. 
    JTable(TableModel dm) 
              Constructs a JTable that is initialized with dm as the data model, a default column model, and a default selection model. 
    JTable(TableModel dm, TableColumnModel cm) 
              Constructs a JTable that is initialized with dm as the data model, cm as the column model, and a default selection model. 
    JTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm) 
              Constructs a JTable that is initialized with dm as the data model, cm as the column model, and sm as the selection model. 
    JTable(Vector rowData, Vector columnNames) 
              Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames.
    Semplicemente il costruttore che hai tentato di usare non esiste.
    Il programmatore lo vedi dal coraggio, dall'altruismo, dalla fantasia...

  3. #3
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    JTable table = new JTable((String[][])array.toArray(), cols);

  4. #4
    Il frammento di codice me lo hanno postato, quindi pensavo fosse tutto ok!. Potresti dirmi come ovviare al problema?

  5. #5
    GRAZIE FLOID ! ADESSO E' TUTTO OK! COMPILA!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.