Bonjour, voici mon issue:
je ne connais pas à l'avance le nombre de lignes de mon jscrollpanel.
Et donc dès que le nombre de lignes est suffisamment élevé, l'utilisateur ne pourra pas voir les lignes de la fin:



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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
 
Voici mon code :
/*
 * 
 *
 * Created on 22 décembre 2008, 10:19
 */
 
package com.fft.555555;
 
import java.util.*;
import javax.swing.*;
import com.fft.tribune.tools.*;
import org.apache.log4j.Logger;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.MessageFormat;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.OrientationRequested;
 
/**
 *
 * @author  300329
 */
public class ????  extends javax.swing.JDialog{
 
 
    private static final Logger log = Logger.getLogger(LstJrnDialogVector.class);
 
    /** A return status code - returned if Cancel button has been pressed */
    public static final int RET_CANCEL = 0;
    /** A return status code - returned if OK button has been pressed */
    public static final int RET_OK = 1;
 
 
    private String cal_id = null;;
    private ListeDesInvitationsModel qtm;
    Object elements[][] = null;
    private boolean isfirstTime;
    private ArrayList tables = new ArrayList();
    private ArrayList tablesCodes = new ArrayList();
    private String date = null;
    private String repas = null;
    private int nbLignes = 0;
    private int total;
 
 
 
    /** Creates new form JDialog */
    public ?????(javax.swing.JDialog parent, boolean modal , String repas , String cal_id, String date) {
        super(parent, modal);
        this.repas = repas;
        this.cal_id = cal_id;
        this.date = date;
 
         try{
            qtm = new ListeDesInvitationsModel();
         }catch(Exception e){
             System.out.println("erreur " + e.getMessage());
         }
 
        queryTableNames();
        initComponents();
        initJrnTable();
 
          /* lstJrnTablex.getColumn(0).setWidth(500);
            lstJrnTablex.getColumn(1).setWidth(500);
            lstJrnTablex.getColumn(2).setWidth(500);*/
 
         lstJrnTablex.setDefaultRenderer(Object.class,  new HeaderCellRenderer2());
      //  lstJrnTablex.setRowHeight(36);
        lstJrnTablex.packAll();
 
 
     //   lstJrnTablex.setSize(1200,1500);//indiquer la hauteur pour toutes les lignes!
      //  lstJrnTablex.getTableHeader().setSize(300,30);//avec entête
 
 
          setVisible(false);
          dispose();
          doClose(RET_OK);
 
 
 
    }
 
 
    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
    public int getReturnStatus() {
        return returnStatus;
    }
 
     public void queryTableNames(){
 
         String temp = "";
         String field = "";
         log.debug("queryTableNames");
         if(repas.equals("MIDI")){
              temp = "select DISTINCT(H1.HOTE_CODE),H1.HOTE_LIBELLE as Repas_Midi "+
                           "from   V_TP_INVITES as I join TP_HOTE as H1 on I.INV_MIDI = H1.HOTE_ID join TP_HOTE as H2 on I.INV_SOIR = H2.HOTE_ID where  INV_CAL_JOUR = 'DAYCODE'" +
                           " AND FIELD <> '0' AND H1.HOTE_CODE <> 'SUP' and H1.HOTE_CODE <> '' "+
                           " order by H1.HOTE_CODE";
 
              field = "H1.HOTE_CODE";
 
         }else{
              temp = "select  DISTINCT(H2.HOTE_CODE),H2.HOTE_LIBELLE  as Repas_Soir "+
                           "from   V_TP_INVITES as I join TP_HOTE as H1 on I.INV_MIDI = H1.HOTE_ID join TP_HOTE as H2 on I.INV_SOIR = H2.HOTE_ID where  INV_CAL_JOUR = 'DAYCODE'" +
                           " AND FIELD <> '0' AND H2.HOTE_CODE <> 'SUP' and H2.HOTE_CODE <> ''"+
                           " order by H2.HOTE_CODE";
 
              field = "H2.HOTE_CODE";
         }
 
 
         //On replace les paramètres dans la requete SQL
        temp = Functions.replace(temp, "DAYCODE", cal_id);
        temp = Functions.replace(temp, "FIELD", field);
        temp = Functions.replace(temp, "INV_TAGREPAS", "inv_"+repas);
 
         Connection c = ContextSingleton.getInstance().getConnection();
         ResultSet results;
 
 
        log.debug(temp);
        try {
            Statement stmt = c.createStatement();
            results = stmt.executeQuery(temp);
 
            while (results.next()) {
                Integer k = new Integer(2);
                String code = results.getString(1);
                String nom = results.getString(2);
                tablesCodes.add(code);
                tables.add(nom);
                log.debug(code);
             }
        }
 
        catch(Exception e){
            System.out.println("exception du a la requete");
 
        }
    }
 
public String defineQuery2(){
 
 
         date = ContextSingleton.getInstance().getFilterDate();
         String query = null;
         log.debug("event type" + ContextSingleton.getInstance().getEventType());
 
 
         if(ContextSingleton.getInstance().getEventType().equals("BERCY")){
 
                query = query1_bercy + ContextSingleton.getInstance().getFilterDate()+ "'" + query_order_1;
 
         }else if(ContextSingleton.getInstance().getEventType().equals("RG")){
         //else{
                query = query1_rg + ContextSingleton.getInstance().getFilterDate()+ "'";
         }
 
 
         log.debug("query liste des jours "+ query);
 
         if(!isfirstTime){
            nbInvites.setText(Integer.toString(lstJrnTablex.getRowCount()));
         }
         else{
             isfirstTime = true;
         }
 
 
         return query;
 
    }
 
    public void initJrnTable() {
 
 
 
 
 
       // qtm.setQueryTotal("SELECT '' as col1, '' as col2, '' as col3");
       qtm.renewVector();
        nbLignes++;
 
 
        int total = 0;
 
        for(int o = 0; o< tables.size(); o++){
 
            String[] blank = {"","",""};
            String tableCode = "Table:"+(String)tables.get(o);
            String table = "Table:"+(String)tablesCodes.get(o);
 
            log.debug( "ajout table " + tableCode );
            String[] q = {tableCode,"",""};
            String[] header = {"Invités","Fonction","Bénéficiaires"};
 
 
            //Nouvelle Table
            //On ajoute le nom de la table
            qtm.addLine(q);
            nbLignes++;
            qtm.addLine(header);
            nbLignes++;
 
            int subtotal = 0;
 
            if(repas.equals("MIDI")){
                    log.debug("c le midi");
                    String queryTable2 = Functions.replace(queryPerTableMidi, "DAYCODE", cal_id);
                    queryTable2 = Functions.replace(queryTable2, "TABLE", table.substring(6,table.length()));
                    log.debug(queryTable2);
 
                    subtotal = qtm.setQuery(queryTable2);
                    nbLignes =  nbLignes+subtotal ;
            }else{
                    log.debug("c le soir");
                    String queryTable2 = Functions.replace(queryPerTableSoir, "DAYCODE", cal_id);
                    queryTable2 = Functions.replace(queryTable2, "TABLE", table.substring(6,table.length()));
                    log.debug(queryTable2);
 
                    subtotal = qtm.setQuery(queryTable2);
                    nbLignes =  nbLignes+subtotal ;
            }
            total += subtotal;
            String[] subTotalLine = {"Total "+new Integer(subtotal).toString(),"",""};
             //Total
             qtm.addLine( subTotalLine );
             nbLignes++;
 
            //Lignes blanches
            qtm.addLine(blank);   nbLignes++;
            qtm.addLine(blank);   nbLignes++;
            qtm.addLine(blank);   nbLignes++;
        }
 
             this.total = total;
             String[] totalLine = {"Nombre Total D'Invités: "+new Integer(total).toString(),"",""};
             //Total
             qtm.addLine( totalLine );
             nbLignes++;
 
        lstJrnTablex.setModel(qtm);
        lstJrnTablex.setDefaultRenderer(String.class, new LstJrnStringRenderer());
        lstJrnTablex.setDefaultRenderer(Boolean.class, new LstJrnCheckBoxRenderer());
        LstJrnStringRenderer centerRenderer = new LstJrnStringRenderer();
        centerRenderer.setHorizontalAlignment(SwingConstants.CENTER);
 
 
    }
 
 
 
    /** 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.
     */
     private void initComponents() {
 
 
 
        okButton = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        lstJrnTablex = new org.jdesktop.swingx.JXTable();
        jLabel1 = new javax.swing.JLabel();
        scrollPane1 = new java.awt.ScrollPane();
        imprimerButton = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        nbInvites = new javax.swing.JLabel();
 
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });
 
 
        okButton.setText("Imprimer");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });
 
        lstJrnTablex.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
 
       javax.swing.JScrollPane jScrollPane1  = new javax.swing.JScrollPane ();
 
        jScrollPane2.setViewportView(lstJrnTablex);
        jLabel1.setFont(new java.awt.Font("MS Sans Serif", 0, 18));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Liste des Jours");
 
           jScrollPane1.setViewportView(lstJrnTablex);
 
        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()
                        .addGap(133, 133, 133)
                        .addComponent(okButton))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(15, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(okButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
 
 
        pack();
    }
 
 
    private void imprimer(){
 
        try {
                MessageFormat header = new MessageFormat("Liste repas du "  + repas + " du "    + date + " ("+ total + ")" );
                MessageFormat footer = new MessageFormat("Page {0,number,integer}");
                PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
                attr.add(OrientationRequested.PORTRAIT );
 
 
                if (! lstJrnTablex
                        .print(JTable.PrintMode.FIT_WIDTH, header, footer, false, attr , false )) {
                    System.out.println("User cancelled printing");
                }
            } catch (java.awt.print.PrinterException e) {
                    System.out.println("Cannot print" + e.getMessage());
            }
 
 
    }
 
 
    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
           imprimer();
    }//GEN-LAST:event_okButtonActionPerformed
 
    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        doClose(RET_CANCEL);
    }//GEN-LAST:event_closeDialog
 
    private void doClose(int retStatus) {
        returnStatus = retStatus;
        setVisible(false);
        dispose();
 
    }
 
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
 
        try { UIManager.setLookAndFeel(
                    //"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                      UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (Exception e) { }
 
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new LstJrnDialogVector(new javax.swing.JFrame(), false).setVisible(false);
            }
        });
    }
 
 
    //Définit correctement la requête SQL
    public String defineQuery(){
 
         date = ContextSingleton.getInstance().getFilterDate();
         String query = null;
 
 
         if(ContextSingleton.getInstance().getEventType().equals("BERCY")){
 
                query = query1_bercy + ContextSingleton.getInstance().getFilterDate()+ "'" + query_order_1;
 
         }
 
         if(!isfirstTime){
            nbInvites.setText(Integer.toString(lstJrnTablex.getRowCount()));
         }
         else{
             isfirstTime = true;
         }
         return query;
    }
 
 
 
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.jdesktop.swingx.JXTable lstJrnTablex;
    private javax.swing.JButton imprimerButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable lstJrnTable;
    private javax.swing.JLabel nbInvites;
    private javax.swing.JButton okButton;
    private java.awt.ScrollPane scrollPane1;
    private javax.swing.JButton repasMidi;
    private javax.swing.JButton repasSoir;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
 
    private int returnStatus = RET_CANCEL;
}
merci de votre aide.