Bonjour à tous,
je sais que le sujet à était vu et revu mais je n'arrive pas à résoudre mon problème pour autant.
Ci dessous mon code :
Ci dessous mon modele :
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 private JPanel _ongletScriptDistant; private JTable _tableAbsentDistant; private JScrollPane _spAbsentDistant; [...] this._tableAbsentDistant=new JTable(new MyTableModel()); this._tableAbsentDistant.getModel().addTableModelListener(this); this._tableAbsentDistant.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); this._tableAbsentDistant.setMinimumSize(new Dimension(700,300)); this._spAbsentDistant=new JScrollPane(this._tableAbsentDistant); this._spAbsentDistant.setMinimumSize(new Dimension(700,300)); con.gridx=1; con.gridy=1; this._ongletAbsentDistante.add(this._spAbsentDistant,con); [...] private void MAJAbsentDistant(ArrayList<ArrayList<String>> listesAbsents, ArrayList<String> listeColonnes) { // TODO Auto-generated method stub for(int x=0;x<listesAbsents.size();x++) { for(int z=0;z<listeColonnes.size();z++) { this._tableAbsentDistant.getModel().setValueAt(listesAbsents, x, z); } } [...]
Si j'initialise mon Modele avec une liste, le premier affichage se fait correctement mais le rafraichissement ne se fait pas.
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
59
60
61
62
63
64
65
66
67
68
69
70
71 package ihm; import java.util.ArrayList; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableModel; public class MyTableModel extends AbstractTableModel { private static final long serialVersionUID = 1L; private ArrayList<String> columnNames; private ArrayList<ArrayList<String>> data; public MyTableModel() { columnNames=new ArrayList<String>(); data=new ArrayList<ArrayList<String>>(); } public MyTableModel(ArrayList<String> colonnes, ArrayList<ArrayList<String>> donnees) { // TODO Auto-generated constructor stub this.columnNames=colonnes; this.data=donnees; } public int getColumnCount() { return columnNames.size(); } public int getRowCount() { return data.size(); } public String getColumnName(int col) { return columnNames.get(col); } public Object getValueAt(int row, int col) { return data.get(row).get(col); } public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } /* * 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. return false; } /* * Don't need to implement this method unless your table's * data can change. */ public void setValueAt(String valeur, int row, int col) { data.get(row).set(col, valeur); fireTableCellUpdated(row, col); } }
Que faire ?
Partager