Salut,
J'essais d'intégrer des cases à cocher dans des tables en créant un model de table qui hérite de AbstractTableModel.
Le problème est au niveau des méthodes setRowCount et insertRow :
je ne sais pas comment les implementer sachant que la structure de donnée du tableau se présente sous un tableau de tableau d'objets (Object [][]).
au cas où:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class MyTableModel extends AbstractTableModel
   {
        private String[] columnNames =
        {"Name",
          "Country",
           "Delay",
           "Team",
           " "
        };
        private Object[][] data =
        {
            {"Mary", "fr",
             "0ms", "fr touch", new Boolean(false)},
            {"Alison", "us",
             "130ms","america", new Boolean(true)}
        };
  public void insertRow(int i,Object[] newrow)
  {
      data.add(newrow);
      super.fireTableDataChanged();
    }
        public int getColumnCount()
        {
            return columnNames.length;
        }
        public int getRowCount()
        {
            return data.length;
        }
        public String getColumnName(int col)
        {
            return columnNames[col];
        }
        public Object getValueAt(int row, int col)
        {
            return data[row][col];
        }
        public Class getColumnClass(int c)
        {
            return getValueAt(0, c).getClass();
        }
        public boolean isCellEditable(int row, int col)
        {
            if (col < 2)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        public void setValueAt(Object value, int row, int col)
        {
            data[row][col] = value;
            fireTableCellUpdated(row, col);
        }
    }
Sur google j'ai trouvé pour des listes de tableaux seulement.
S'il vous plait, aidez moi ! Merci !