Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 12 su 12
  1. #11
    Utente di HTML.it L'avatar di gax80
    Registrato dal
    May 2006
    Messaggi
    631
    senti volevo sapere come si fa ad aggiungere un certo numero di righe usando il TableModel?

    questo è il mio codice ma nn capisco dovè l'errore

    codice:
    class MyTableModel extends AbstractTableModel implements TableModelListener
    {
        // public Object[][] data =new Object[99][6];
        //
    //public Object[][] data= {  { new Boolean(false),"zagarolo", "Campione", "Snowboarding", new Integer(5), "ZAGA", "la mam di nicola"}};
    public Record[] r= new Record[99];    
    public Object[][] data= 
        {  { new Boolean(false),"zagarolo", "Campione", "Snowboarding", new Integer(5), "ZAGA", "la mam di nicola"},
           { new Boolean(false),"zagarolo", "Campione", "Snowboarding", new Integer(5), "ZAGA", "la mam di nicola"}};
    public TableModel tm = new TableModel(); 
    public JTable tt= new JTable();
        private boolean DEBUG = false;
          private  String[] columnNames ={"s", "nome", "indirizzo", "path", "dimensione","directory", "contenuto"};
    //private Object[][] data = {};
            
            
       
            public void MyTable(Object[][] data, int co, Record[] r) {
            int i=0;
            
                //while(i!=co){
                this.data=data;
                tm.addTableModelListener(e);
             
           // i++;}
            //addRow(TableModelEvent e);
            //System.out.println(r[i].getCliente());
            }
       //     public Object dato(Object data)
       //     {
     //return data;     
    //}
           
            
            public int getColumnCount() {
            try{}
            catch(Exception e){}
            return columnNames.length;
        }
    
        public int getRowCount() {try{}
            catch(Exception e){}
            return data.length;
        }
    
        public String getColumnName(int col) {
           try{}
            catch(Exception e){} return columnNames[col];
        }
    
        public Object getValueAt(int row, int col) {
            try{}
            catch(Exception e){}return data[row][col];
        }
    
        public Class getColumnClass(int c) {
            try{}
            catch(Exception e){}return getValueAt(0, c).getClass();
        }
    
        public void addTableModelListener(TableModelEvent e) {
    int col = e.getColumn();
    int row = e.getFirstRow();
         }
         
        
        /*
         * Don't need to implement this method unless your table's
         * editable.
         */
        public boolean isCellEditable(int row, int col) {
            //Note that the data/cell address is constant,
            //no matter where the cell appears onscreen.
          
                if (col < 0) {
                return false;
            } else {
                return true;
            }
        }     
              
        
    
    
        /*
         * Don't need to implement this method unless your table's
         * data can change.
         */
        public void setValueAt(Object value, int row, int col) {
                if (DEBUG) {
                    System.out.println("Setting value at " + row + "," + col
                                       + " to " + value
                                       + " (an instance of "
                                       + value.getClass() + ")");
                }
    
                data[row][col] = value;
                fireTableCellUpdated(row, col);
    
                if (DEBUG) {
                    System.out.println("New value of data:");
                    printDebugData();
                }
            }
    
            private void printDebugData() {
                int numRows = getRowCount();
                int numCols = getColumnCount();
    
                for (int i=0; i < numRows; i++) {
                    System.out.print("    row " + i + ":");
                    for (int j=0; j < numCols; j++) {
                        System.out.print("  " + data[i][j]);
                    }
                    System.out.println();
                }
                System.out.println("--------------------------");
            }
        }
    quando il diavolo ti accarezza è perchè vuole la tua anima

  2. #12
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,487

    Moderazione

    Originariamente inviato da gax80
    senti volevo sapere come si fa ad aggiungere un certo numero di righe usando il TableModel?
    Ne stai già parlando in più di una discussione (qui, qui e qui.)

    Questa è conclusa da tempo, risale addirittura all'anno scorso.

    Invito per l'ennesima volta ad un uso corretto del forum.
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

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 © 2026 vBulletin Solutions, Inc. All rights reserved.