Bonjour à tous !

Voilou, je rencontre un petit problème dans l'application que je développe actuellement...

J'affiche un jtable à l'intérieur d'un scrollpane.Lorsque j'ajoute des lignes à mon jtable, pas de problème, le scrollpane suit et permet le défilement vertical...

Malheureusement, le défilement horizontal est quand à lui impossible !

En effet, lorsque je veux changer la largeur de mon jtable, le scrollpane ne le prends pas en compte...La scrollbar verticale apparait mais pas "la barre amovible" qui permet normalement le défilement...

Si jamais, voici mon code (générée avec netbeans ^^)...

D'avance, je vous remercie ! :-)

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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
package gui;
 
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
 
public class FrameDetailsComte extends javax.swing.JFrame {
 
    /** Creates new form FrameDetailsComte */
    public FrameDetailsComte(String[] comte) {
        initComponents(comte);
        this.setTitle("Détails du comté de "+comte[4]+" dans l'état du "+comte[3]);
        this.jTableDetailsComte.getColumn(this.jTableDetailsComte.getModel().getColumnName(0)).setMaxWidth(18);
        this.jTableDetailsComte.getColumn(this.jTableDetailsComte.getModel().getColumnName(0)).setMinWidth(18);
        Container c =  new Container();
        c.setSize(700, 700);
        LayoutManager l = this.jScrollPaneDetailsComte.getLayout();
 
    }
 
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents(String[] comte) {
 
        jScrollPaneDetailsComte = new javax.swing.JScrollPane();
        jTableDetailsComte = new javax.swing.JTable();
        bFermerDetailsComte = new javax.swing.JButton();
 
        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
 
        jScrollPaneDetailsComte.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPaneDetailsComte.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
 
        jTableDetailsComte.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, "Hommes", comte[6]},
                {null, "Femmes", comte[7]}
            },
            new String [] {
                "", "", ""
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };
 
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        this.jTableDetailsComte.setPreferredSize(new Dimension(700,700));
        this.jTableDetailsComte.setMaximumSize(new Dimension(700,700));
        this.jTableDetailsComte.setMinimumSize(new Dimension(700,700));
        this.jTableDetailsComte.setSize(new Dimension(700,700));
        jScrollPaneDetailsComte.setViewportView(jTableDetailsComte);
 
        bFermerDetailsComte.setText("Fermer");
        bFermerDetailsComte.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                bFermerDetailsComteMousePressed(evt);
            }
        });
        Dimension d = new Dimension();
        /*d.setSize(700, 700);
        this.jTableDetailsComte.setSize(d);
        this.jTableDetailsComte.setMaximumSize(d);
        this.jTableDetailsComte.setMinimumSize(d);*/
 
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPaneDetailsComte, javax.swing.GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(261, 261, 261)
                        .addComponent(bFermerDetailsComte)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPaneDetailsComte, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bFermerDetailsComte)
                .addContainerGap())
        );
 
        pack();
    }// </editor-fold>
 
private void bFermerDetailsComteMousePressed(java.awt.event.MouseEvent evt) {
	this.dispose();
}
 
    // Variables declaration - do not modify
    private javax.swing.JButton bFermerDetailsComte;
    private javax.swing.JScrollPane jScrollPaneDetailsComte;
    private javax.swing.JTable jTableDetailsComte;
    // End of variables declaration
 
}