Bonjour, je rencontre un nouveau problème. Cela concerne mes JTable. J'y affecte un rowsorter mais lorsque je clique sur les entètes, les lignes ne se triens pas alors que le petit triangle qui indique l'ordre s'affiche. En gros aucun ne se fait, comme si toutes les valeurs étaient toutes égales.

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
 
public class Table extends JTable {
 
    private TableModel model;
    private TableRowSorter<TableModel> sorter;
    private ArrayList<RowSorter.SortKey> listSorter;
 
 
    public Table (String[] titles, ResultSet resultSet, int minimumRowCount) {
        super();
        model = new TableModel(titles, resultSet, minimumRowCount);
        setModel(model);
 
        listSorter = new ArrayList<RowSorter.SortKey>();
        sorter = new TableRowSorter<TableModel>(model);
        listSorter.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
        try {sorter.setSortKeys(listSorter);}
        catch(IllegalArgumentException ex ){ex.printStackTrace();}
 
        try {setRowSorter(sorter);}
        catch (IllegalArgumentException iae){iae.printStackTrace();}
        listSorter.clear();
    }
}
Le modèle si venait de là

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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
 
public class TableModel extends AbstractTableModel {
 
    private String[] titles;
    private ResultSet resultSet;
 
    private int minimumRowCount;//number of minimum shown rows. If data is not big enouth,
                    //complet table with null value
    private int maximumRowCount;//number of maximum rows displayed.
                    //Include shown ans hidden rows
 
 
    public TableModel() {
    }
 
 
    public TableModel(String[] titles, ResultSet resultSet, int minimumRowCount){
        this.titles = titles;
        this.resultSet = resultSet;
        try {
            resultSet.last();
            maximumRowCount = resultSet.getRow();
            resultSet.beforeFirst();
        }
        catch (SQLException sql) {
            currentRowCount = minimumRowCount;
        }
    }
 
    /**
     * 
     * @return the number of columns in the model
     * Returns the number of columns in the model.
     * A Table uses this method to determine how many columns it should create
     * and display by default.
     */
    public int getColumnCount() {
        return titles.length;
    }
 
    /**
     *
     * @return the number of rows in the model
     * Returns the number of rows in the model. A JTable uses this method to
     * determine how many rows it should display. This method should be quick,
     * as it is called frequently during rendering.
     */
    public int getRowCount() {
        return currentRowCount;
    }
 
    /**
     * 
     * @param parm1 the row whose value is to be queried
     * @param parm2 the collumn whose value is to be queried
     */
    public Object getValueAt(int parm1, int parm2) {
        try {
            resultSet.absolute(parm1+1);
            return resultSet.getString(parm2+1);
        }
        catch(SQLException sql){sql.printStackTrace();return null;}
    }
 
    /**
     *
     * @param col
     */
    public String getColumnName(int col) {
        return titles[col];
    }
 
    /**
     *
     * @param rowIndex
     * @param columnIndex
     */
    public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
    }
 
 
    public void setMinimumRowCount(int minimumRowCount) {
        this.minimumRowCount = minimumRowCount;
    }
 
}
Merci d'avance