Bonjour a tous,

J ai une erreur au nieau du try....catch.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
error: unreported exception SQLException; must be caught or declared to be thrown jTxtMatrFocusLost(e);
Quelqu un pourrait-il me dire l origine de l erreur
Merci d avance

Habiler
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
 
package decisions;
 
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.beans.*;
import java.sql.*;
import javax.swing.*;
import java.util.Calendar;
import javax.swing.border.*;
import com.toedter.calendar.*;
import java.beans.PropertyChangeListener;
import static java.lang.Math.exp;
import java.util.logging.Level;
import java.util.logging.Logger;
 
 
public class AddDecisionsJFrame1 extends JFrame {
 
Connection conn =null;
ResultSet rs = null;
PreparedStatement ps = null;
 
 
 
public AddDecisionsJFrame1() throws SQLException {
 
        initComponents();
         conn = Connect.ConnectDB();
        jDateChooserPostposeDebut.setVisible(false);
        jDateChooserPostposeFin.setVisible(false);
        jTextNom_Parent.setVisible(false);
        String Mat = jTxtMatr.getText();
        FilljCboTypeAbsence();
      //  FilljTxtNomPrenom();
    }
   static Void affiche(String message) {
      System.out.println(message);
     return null;
   }
 
//   private Object oui;
 
    /**
     * Creates new form DeciiJFrame
     */
@SuppressWarnings("empty-statement")
    private void jDateChooserDateFinPropertyChange(PropertyChangeEvent e) {
    NullPointerException exp;
    jDateChooserDateFin.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(java.beans.PropertyChangeEvent evt1) {
            if (evt1.getPropertyName().equals("date")) {
                if (jDateChooserDateDebut.getCalendar() == null) {
                    JOptionPane.showMessageDialog(null,
                            "La date de début est nulle !!!.",
                            " Avertissement", JOptionPane.WARNING_MESSAGE);;
                } else
 
                {
                    if (jDateChooserDateFin.getCalendar().before(jDateChooserDateDebut.getCalendar()))
                    {
                        JOptionPane.showMessageDialog(null,
                                "La date de début est "
                                        + "supérieure à la date de fin !!!.",
                                " Avertissement", JOptionPane.WARNING_MESSAGE);;
                    } else
 
                    {
                        System.out.println("bon d'accord ...");
                    }
                } }
            {
                Calendar sDate = Calendar.getInstance();
                Calendar eDate = Calendar.getInstance();
                sDate.setTime(jDateChooserDateFin.getDate());
                eDate.setTime(jDateChooserDateDebut.getDate());
                int difInMonths = sDate.get(Calendar.MONTH) - eDate.get(Calendar.MONTH);
                JOptionPane.showMessageDialog(null,""+difInMonths+" mois","Nombre de mois !!!",JOptionPane.PLAIN_MESSAGE);
                System.out.println(""+difInMonths+"");
            }
        }
    });   
    }
 
    private void jDateChooserPostposeFinPropertyChange(PropertyChangeEvent e) {
    NullPointerException exp;
     jDateChooserPostposeFin.addPropertyChangeListener(new PropertyChangeListener() {
                  @Override
                  public void propertyChange(java.beans.PropertyChangeEvent evt1) {
                      if (evt1.getPropertyName().equals("date")) {
                          if (jDateChooserPostposeDebut.getCalendar() == null) {
                              JOptionPane.showMessageDialog(null,
                                      "La date de début est nulle !!!.",
                                      " Avertissement", JOptionPane.WARNING_MESSAGE);;
                          } else {
                              if (jDateChooserPostposeFin.getCalendar().before(jDateChooserPostposeDebut.getCalendar())) {
                                  JOptionPane.showMessageDialog(null,
                                          "La date de début est inférieure à la date de fin !!!.",
                                          " Avertissement", JOptionPane.WARNING_MESSAGE);;
                              } else {
                                  System.out.println("bon d'accord ...");
                              }
                          }
                      }
                  }
              });
      // TODO add your code here
    }
public final void FilljCboTypeAbsence() {
    try{
 
       String sql = "SELECT Type FROM Typedossier";
       ps = conn.prepareStatement(sql);
       rs = ps.executeQuery();
 
 
        while (rs.next()){
        jCboTypeAbsence.addItem(rs.getString("Type"));    
 
                }
    }    catch(SQLException e) {
 
        JOptionPane.showMessageDialog(null, e);
    }
 
}
 
private void jTxtMatrFocusLost(FocusEvent e) throws SQLException {
 
                PreparedStatement ps1;
                Connection conn = Connect.ConnectDB();
 
                String SQL1 = "SELECT * FROM Signaletique where Matricule = ?";
 
                    affiche("1") ;   
            try{ 
                    ps1 = conn.prepareStatement(SQL1); 
 
                    ps1.setString(1,jTxtMatr.getText());  
                    ResultSet rs1 = ps1.executeQuery();
                     affiche("Matr :"+jTxtMatr.getText()) ;
 
                       while ( rs1.next() ) {
                    System.out.println("ID :"+rs1.getInt(1));       
                      affiche("3") ;
                            // MatriculeFinded.setText(rs.getString(1));
                            jTxtNomPrenom.setText(rs1.getString(2));
                            //PrenomFinded.setText(rs.getString(3));
 
          affiche("Etape 5");                    
                 //Display values
 
 
 
 
                System.out.println("Last Name :"+rs1.getString(3));
 
                System.out.println("Designation :"+rs1.getString(4));
 
                System.out.println("-------------------");
                            }
 
 
        rs1.close();
        } catch (SQLException ex) {
        }
}
    // TODO add your code here
 
 
 
/*public final void FilljTxtNomPrenom() throws SQLException {
 
                PreparedStatement ps1;
                Connection conn = Connect.ConnectDB();
                      
                String SQL1 = "SELECT * FROM Signaletique where Matricule = ?";
                     
               	try {
                    affiche("1") ;   
                   
                    ps1 = conn.prepareStatement(SQL1); 
                 
                    ps1.setString(1,jTxtMatr.getText());  
                    ResultSet rs1 = ps1.executeQuery();
                     affiche("Matr :"+jTxtMatr.getText()) ;
               
                       while ( rs1.next() ) {
                    System.out.println("ID :"+rs1.getInt(1));       
                      affiche("3") ;
                            // MatriculeFinded.setText(rs.getString(1));
                            jTxtNomPrenom.setText(rs1.getString(2));
                            //PrenomFinded.setText(rs.getString(3));
                            
          affiche("Etape 5");                    
                 //Display values
                
 
                
 
                System.out.println("Last Name :"+rs1.getString(3));
 
                System.out.println("Designation :"+rs1.getString(4));
 
                System.out.println("-------------------");
                            }
                                                 
                                                                    
           ps.close();
                    } catch (SQLException e) {
		}
    }        */   
 
 
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    private void initComponents() {
        jLabel1 = new JLabel();
        CmdSave = new JButton();
        jLabel2 = new JLabel();
        TxtDecId = new JTextField();
        jLabel3 = new JLabel();
        jLabel4 = new JLabel();
        TxtNumero = new JTextField();
        jLabel5 = new JLabel();
        jLabel6 = new JLabel();
        jLabel7 = new JLabel();
        jTxtMatr = new JTextField();
        jLabel8 = new JLabel();
        jLabel9 = new JLabel();
        jCheckBoxRefus = new JCheckBox();
        jLabel10 = new JLabel();
        jCheckBox3 = new JCheckBox();
        jCheckBoxPostpose = new JCheckBox();
        jLabel12 = new JLabel();
        jCboPcActivity = new JComboBox<>();
        jCboTypeAbsence = new JComboBox<>();
        jCheckBoxVen1 = new JCheckBox();
        TxtId = new JTextField();
        jDateChooserDateDebut = new JDateChooser();
        jDateChooserDateFin = new JDateChooser();
        jCheckBoxLun1 = new JCheckBox();
        jCheckBoxMar1 = new JCheckBox();
        jCheckBoxMer1 = new JCheckBox();
        jCheckBoxJeu1 = new JCheckBox();
        jCheckBoxVen2 = new JCheckBox();
        jCheckBoxLun2 = new JCheckBox();
        jCheckBoxMar2 = new JCheckBox();
        jCheckBoxMer2 = new JCheckBox();
        jCheckBoxJeu2 = new JCheckBox();
        jScrollPane1 = new JScrollPane();
        jTextAreaRemarques = new JTextArea();
        jLabel11 = new JLabel();
        jCboFiliation = new JComboBox<>();
        jTextNom_Parent = new JTextField();
        jDateChooserDateDec = new JDateChooser();
        jDateChooserPostposeDebut = new JDateChooser();
        jDateChooserPostposeFin = new JDateChooser();
        jTxtNomPrenom = new JTextField();
 
        //======== this ========
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("A");
        setBackground(new Color(102, 255, 204));
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        Container contentPane = getContentPane();
        contentPane.setLayout(null);
 
        //---- jLabel1 ----
        jLabel1.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel1.setText("Id");
        contentPane.add(jLabel1);
        jLabel1.setBounds(24, 42, 28, jLabel1.getPreferredSize().height);
 
        //---- CmdSave ----
        CmdSave.setText("Save record");
        CmdSave.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                CmdSaveMouseClicked(e);
            }
        });
        contentPane.add(CmdSave);
        CmdSave.setBounds(new Rectangle(new Point(400, 430), CmdSave.getPreferredSize()));
 
        //---- jLabel2 ----
        jLabel2.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel2.setText("DecId");
        contentPane.add(jLabel2);
        jLabel2.setBounds(new Rectangle(new Point(24, 68), jLabel2.getPreferredSize()));
        contentPane.add(TxtDecId);
        TxtDecId.setBounds(140, 65, 91, TxtDecId.getPreferredSize().height);
 
        //---- jLabel3 ----
        jLabel3.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel3.setText("Matricule");
        contentPane.add(jLabel3);
        jLabel3.setBounds(24, 94, 47, jLabel3.getPreferredSize().height);
 
        //---- jLabel4 ----
        jLabel4.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel4.setText("Numero");
        contentPane.add(jLabel4);
        jLabel4.setBounds(24, 150, jLabel4.getPreferredSize().width, 18);
        contentPane.add(TxtNumero);
        TxtNumero.setBounds(140, 150, 91, TxtNumero.getPreferredSize().height);
 
        //---- jLabel5 ----
        jLabel5.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel5.setText("Date d\u00e9cision");
        contentPane.add(jLabel5);
        jLabel5.setBounds(new Rectangle(new Point(24, 119), jLabel5.getPreferredSize()));
 
        //---- jLabel6 ----
        jLabel6.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel6.setText("D\u00e9but de l'absence");
        contentPane.add(jLabel6);
        jLabel6.setBounds(20, 240, jLabel6.getPreferredSize().width, 20);
 
        //---- jLabel7 ----
        jLabel7.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel7.setText("Fin de l'absence");
        contentPane.add(jLabel7);
        jLabel7.setBounds(20, 270, 98, 20);
 
        //---- jTxtMatr ----
        jTxtMatr.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                jTxtMatrFocusLost(e);
            }
        });
        contentPane.add(jTxtMatr);
        jTxtMatr.setBounds(140, 90, 91, jTxtMatr.getPreferredSize().height);
 
        //---- jLabel8 ----
        jLabel8.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel8.setText("Pc d'activit\u00e9");
        contentPane.add(jLabel8);
        jLabel8.setBounds(18, 180, 110, 20);
 
        //---- jLabel9 ----
        jLabel9.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel9.setText("Type d'absence");
        contentPane.add(jLabel9);
        jLabel9.setBounds(20, 210, jLabel9.getPreferredSize().width, 20);
        contentPane.add(jCheckBoxRefus);
        jCheckBoxRefus.setBounds(new Rectangle(new Point(140, 300), jCheckBoxRefus.getPreferredSize()));
 
        //---- jLabel10 ----
        jLabel10.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel10.setText("Refus");
        contentPane.add(jLabel10);
        jLabel10.setBounds(20, 300, 100, 20);
        contentPane.add(jCheckBox3);
        jCheckBox3.setBounds(new Rectangle(new Point(140, 300), jCheckBox3.getPreferredSize()));
 
        //---- jCheckBoxPostpose ----
        jCheckBoxPostpose.addActionListener(e -> jCheckBoxPostposeActionPerformed(e));
        contentPane.add(jCheckBoxPostpose);
        jCheckBoxPostpose.setBounds(new Rectangle(new Point(140, 330), jCheckBoxPostpose.getPreferredSize()));
 
        //---- jLabel12 ----
        jLabel12.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel12.setText("Pospos\u00e9");
        jLabel12.setRequestFocusEnabled(false);
        contentPane.add(jLabel12);
        jLabel12.setBounds(new Rectangle(new Point(20, 330), jLabel12.getPreferredSize()));
 
        //---- jCboPcActivity ----
        jCboPcActivity.setModel(new DefaultComboBoxModel<>(new String[] {
            "0",
            "10",
            "20",
            "30",
            "40",
            "50",
            "60",
            "70",
            "85",
            "90",
            "100"
        }));
        jCboPcActivity.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        jCboPcActivity.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                jCboPcActivityFocusLost(e);
            }
        });
        contentPane.add(jCboPcActivity);
        jCboPcActivity.setBounds(140, 180, jCboPcActivity.getPreferredSize().width, 20);
 
        //---- jCboTypeAbsence ----
        jCboTypeAbsence.setSelectedIndex(-1);
        contentPane.add(jCboTypeAbsence);
        jCboTypeAbsence.setBounds(140, 210, 180, jCboTypeAbsence.getPreferredSize().height);
 
        //---- jCheckBoxVen1 ----
        jCheckBoxVen1.setText("Vendredi");
        jCheckBoxVen1.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
        jCheckBoxVen1.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
        contentPane.add(jCheckBoxVen1);
        jCheckBoxVen1.setBounds(new Rectangle(new Point(390, 320), jCheckBoxVen1.getPreferredSize()));
        contentPane.add(TxtId);
        TxtId.setBounds(140, 40, 90, TxtId.getPreferredSize().height);
 
        //---- jDateChooserDateDebut ----
        jDateChooserDateDebut.setDateFormatString("dd/MM/yyyy");
        jDateChooserDateDebut.setFocusCycleRoot(true);
        jDateChooserDateDebut.setDate(null);
        jDateChooserDateDebut.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED));
        contentPane.add(jDateChooserDateDebut);
        jDateChooserDateDebut.setBounds(new Rectangle(new Point(140, 240), jDateChooserDateDebut.getPreferredSize()));
 
        //---- jDateChooserDateFin ----
        jDateChooserDateFin.setDateFormatString("dd/MM/yyyy");
        jDateChooserDateFin.setFocusCycleRoot(true);
        jDateChooserDateFin.setBorder(new BevelBorder(BevelBorder.LOWERED));
        jDateChooserDateFin.setDate(null);
        jDateChooserDateFin.addPropertyChangeListener(e -> jDateChooserDateFinPropertyChange(e));
        contentPane.add(jDateChooserDateFin);
        jDateChooserDateFin.setBounds(new Rectangle(new Point(140, 270), jDateChooserDateFin.getPreferredSize()));
 
        //---- jCheckBoxLun1 ----
        jCheckBoxLun1.setText("Lundi");
        jCheckBoxLun1.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
        jCheckBoxLun1.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
        contentPane.add(jCheckBoxLun1);
        jCheckBoxLun1.setBounds(new Rectangle(new Point(390, 240), jCheckBoxLun1.getPreferredSize()));
 
        //---- jCheckBoxMar1 ----
        jCheckBoxMar1.setText("Mardi");
        jCheckBoxMar1.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
        jCheckBoxMar1.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
        contentPane.add(jCheckBoxMar1);
        jCheckBoxMar1.setBounds(new Rectangle(new Point(390, 260), jCheckBoxMar1.getPreferredSize()));
 
        //---- jCheckBoxMer1 ----
        jCheckBoxMer1.setText("Mercredi");
        jCheckBoxMer1.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
        jCheckBoxMer1.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
        contentPane.add(jCheckBoxMer1);
        jCheckBoxMer1.setBounds(new Rectangle(new Point(390, 280), jCheckBoxMer1.getPreferredSize()));
 
        //---- jCheckBoxJeu1 ----
        jCheckBoxJeu1.setText("Jeudi");
        jCheckBoxJeu1.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
        jCheckBoxJeu1.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
        contentPane.add(jCheckBoxJeu1);
        jCheckBoxJeu1.setBounds(new Rectangle(new Point(390, 300), jCheckBoxJeu1.getPreferredSize()));
 
        //---- jCheckBoxVen2 ----
        jCheckBoxVen2.setText("Vendredi");
        jCheckBoxVen2.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
        jCheckBoxVen2.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
        contentPane.add(jCheckBoxVen2);
        jCheckBoxVen2.setBounds(new Rectangle(new Point(470, 320), jCheckBoxVen2.getPreferredSize()));
 
        //---- jCheckBoxLun2 ----
        jCheckBoxLun2.setText("Lundi");
        jCheckBoxLun2.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
        jCheckBoxLun2.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
        contentPane.add(jCheckBoxLun2);
        jCheckBoxLun2.setBounds(new Rectangle(new Point(470, 240), jCheckBoxLun2.getPreferredSize()));
 
        //---- jCheckBoxMar2 ----
        jCheckBoxMar2.setText("Mardi");
        jCheckBoxMar2.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
        jCheckBoxMar2.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
        contentPane.add(jCheckBoxMar2);
        jCheckBoxMar2.setBounds(new Rectangle(new Point(470, 260), jCheckBoxMar2.getPreferredSize()));
 
        //---- jCheckBoxMer2 ----
        jCheckBoxMer2.setText("Mercredi");
        jCheckBoxMer2.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
        jCheckBoxMer2.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
        contentPane.add(jCheckBoxMer2);
        jCheckBoxMer2.setBounds(new Rectangle(new Point(470, 280), jCheckBoxMer2.getPreferredSize()));
 
        //---- jCheckBoxJeu2 ----
        jCheckBoxJeu2.setText("Jeudi");
        jCheckBoxJeu2.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
        jCheckBoxJeu2.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
        contentPane.add(jCheckBoxJeu2);
        jCheckBoxJeu2.setBounds(new Rectangle(new Point(470, 300), jCheckBoxJeu2.getPreferredSize()));
 
        //======== jScrollPane1 ========
        {
 
            //---- jTextAreaRemarques ----
            jTextAreaRemarques.setColumns(20);
            jTextAreaRemarques.setFont(new Font("Cambria", Font.PLAIN, 11));
            jTextAreaRemarques.setLineWrap(true);
            jTextAreaRemarques.setRows(5);
            jTextAreaRemarques.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
            jScrollPane1.setViewportView(jTextAreaRemarques);
        }
        contentPane.add(jScrollPane1);
        jScrollPane1.setBounds(new Rectangle(new Point(150, 390), jScrollPane1.getPreferredSize()));
 
        //---- jLabel11 ----
        jLabel11.setFont(new Font("Times New Roman", Font.BOLD, 11));
        jLabel11.setText("Remarques :");
        contentPane.add(jLabel11);
        jLabel11.setBounds(21, 390, 70, jLabel11.getPreferredSize().height);
 
        //---- jCboFiliation ----
        jCboFiliation.setModel(new DefaultComboBoxModel<>(new String[] {
            "<None>",
            "Fils",
            "Fille",
            "P\u00e8re",
            "M\u00e8re",
            "Fr\u00e8re",
            "Soeur",
            "Beau-p\u00e8re",
            "Belle-m\u00e8re"
        }));
        jCboFiliation.addActionListener(e -> jCboFiliationActionPerformed(e));
        contentPane.add(jCboFiliation);
        jCboFiliation.setBounds(330, 210, 100, jCboFiliation.getPreferredSize().height);
        contentPane.add(jTextNom_Parent);
        jTextNom_Parent.setBounds(440, 210, 160, jTextNom_Parent.getPreferredSize().height);
 
        //---- jDateChooserDateDec ----
        jDateChooserDateDec.setDateFormatString("dd/MM/yyyy");
        jDateChooserDateDec.setFocusCycleRoot(true);
        jDateChooserDateDec.setBorder(new BevelBorder(BevelBorder.LOWERED));
        jDateChooserDateDec.setMaxSelectableDate(new java.util.Date(253370764880000L));
        jDateChooserDateDec.setDate(null);
        contentPane.add(jDateChooserDateDec);
        jDateChooserDateDec.setBounds(new Rectangle(new Point(140, 120), jDateChooserDateDec.getPreferredSize()));
 
        //---- jDateChooserPostposeDebut ----
        jDateChooserPostposeDebut.setDateFormatString("dd/MM/yyyy");
        jDateChooserPostposeDebut.setFocusCycleRoot(true);
        jDateChooserPostposeDebut.setBorder(new BevelBorder(BevelBorder.LOWERED));
        jDateChooserPostposeDebut.setDate(null);
        contentPane.add(jDateChooserPostposeDebut);
        jDateChooserPostposeDebut.setBounds(new Rectangle(new Point(165, 330), jDateChooserPostposeDebut.getPreferredSize()));
 
        //---- jDateChooserPostposeFin ----
        jDateChooserPostposeFin.setDateFormatString("dd/MM/yyyy");
        jDateChooserPostposeFin.setFocusCycleRoot(true);
        jDateChooserPostposeFin.setBorder(new BevelBorder(BevelBorder.LOWERED));
        jDateChooserPostposeFin.setDate(null);
        jDateChooserPostposeFin.addPropertyChangeListener(e -> jDateChooserPostposeFinPropertyChange(e));
        contentPane.add(jDateChooserPostposeFin);
        jDateChooserPostposeFin.setBounds(new Rectangle(new Point(275, 330), jDateChooserPostposeFin.getPreferredSize()));
        contentPane.add(jTxtNomPrenom);
        jTxtNomPrenom.setBounds(340, 40, 230, jTxtNomPrenom.getPreferredSize().height);
 
        { // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < contentPane.getComponentCount(); i++) {
                Rectangle bounds = contentPane.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = contentPane.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            contentPane.setMinimumSize(preferredSize);
            contentPane.setPreferredSize(preferredSize);
        }
        pack();
        setLocationRelativeTo(getOwner());
    }// </editor-fold>//GEN-END:initComponents
 
 
    private void CmdSaveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CmdSaveMouseClicked
    NullPointerException exp;
        conn = Connect.ConnectDB();
try{
 
String sql = "Insert INTO Decisions (Id,DecId,Matr,Datedec,numero,Debut,Fin,Pourcent,AbsType,Refus,Postpose,Post_Debut,Post_Fin,Lu1,Ma1,Me1,Je1,Ve1,Lu2,Ma2,Me2,Je2,Ve2,Remarques,Filiation, Nom_Parent)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
 
PreparedStatement ps = conn.prepareStatement(sql);
 
 
ps.setString(1,TxtId.getText()); // à voir si tu dois utiliser ps.setInt()
 
 //TxtDecId - Gestion de valeur Null
 //---------------------------------
 
   if (TxtDecId.getText().equals("")){
     ps.setString(2, "");
    }
     else {
        ps.setString(2, TxtDecId.getText());
    }
 
        ps.setString(3,jTxtMatr.getText());
 
 
//jDateChooserDateDec- Gestion de valeur Null
// ==========================================
 
if ( jDateChooserDateDec.getDate() == null){ 
   ps.setDate(4,null); 
    }  else { 
    ps.setDate(4,new java.sql.Date(jDateChooserDateDec.getDate().getTime()));
    }
 
ps.setString(5,TxtNumero.getText());
 
//jDateChooserDateDebut - Gestion de valeur Null
    // ==========================================
 
    if ( jDateChooserDateDebut.getDate() == null){ 
   ps.setDate(6,null); 
    }  else { 
    ps.setDate(6,new java.sql.Date(jDateChooserDateDebut.getDate().getTime()));
    }
 
    //jDateChooserDateDebut - Gestion de valeur Null
    // ==========================================
 
    if ( jDateChooserDateFin.getDate() == null){ 
   ps.setDate(7,null); 
    }  else { 
    ps.setDate(7,new java.sql.Date(jDateChooserDateFin.getDate().getTime()));
    }
 
ps.setObject(8, jCboPcActivity.getSelectedItem());
ps.setObject(9,jCboTypeAbsence.getSelectedItem());
ps.setObject(10, jCheckBoxRefus.isSelected());
ps.setObject(11, jCheckBoxPostpose.isSelected());
 
 //jDateChooser PostposeDebut - Gestion de valeur Null
 //===================================================
 
if ( jDateChooserPostposeDebut.getDate() == null){ 
   ps.setDate(12,null); 
    }  else { 
    ps.setDate(12,new java.sql.Date(jDateChooserPostposeDebut.getDate().getTime()));
    }
// ps.setDate(12,new java.sql.Date(jDateChooserPostposeDebut.getDate().getTime()));
 
 //jDateChooser PostposeDebut - Gestion de valeur Null
 //===================================================
 
if ( jDateChooserPostposeFin.getDate() == null){ 
   ps.setDate(13,null); 
    }  else { 
    ps.setDate(13,new java.sql.Date(jDateChooserPostposeFin.getDate().getTime()));
    }
 
//ps.setDate(13,new java.sql.Date(jDateChooserPostposeFin.getDate().getTime()));
 
ps.setObject(14, jCheckBoxLun1.isSelected());
ps.setObject(15, jCheckBoxMar1.isSelected());
ps.setObject(16, jCheckBoxMer1.isSelected());
ps.setObject(17, jCheckBoxJeu1.isSelected());
ps.setObject(18, jCheckBoxVen1.isSelected());
ps.setObject(19, jCheckBoxLun2.isSelected());
ps.setObject(20, jCheckBoxMar2.isSelected());
ps.setObject(21, jCheckBoxMer2.isSelected());
ps.setObject(22, jCheckBoxJeu2.isSelected());
ps.setObject(23, jCheckBoxVen2.isSelected());
ps.setString(24, jTextAreaRemarques.getText());
ps.setObject(25, jCboFiliation.getSelectedItem());
 
// jTextNom_Parent - Gestion de valeur Null
// ========================================
 
     if (jTextNom_Parent.getText().equals("")){
      ps.setString(26, "");
    }
    else {
       ps.setString(26, jTextNom_Parent.getText());
   }
 
 //      jTxtNomPrenom.add(jTxtMatr, this);
 ps.execute();
 
 
          JOptionPane.showMessageDialog(null, "Saved");
            conn.close();
}
         catch(SQLException | HeadlessException e )
 
{ 
            JOptionPane.showMessageDialog(null, e);
            e.printStackTrace();
        }             
    }
 
 
/*
    }//GEN-LAST:event_CmdSaveMouseClicked
*/
    private void jCboPcActivityFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jCboPcActivityFocusLost
    NullPointerException exp;
        String x = String.valueOf(jCboPcActivity.getSelectedItem());
        if (x.equals("100")) {
 
          jCheckBoxLun1.setSelected(true);
          jCheckBoxMar1.setSelected(true);
          jCheckBoxMer1.setSelected(true);
          jCheckBoxJeu1.setSelected(true);
          jCheckBoxVen1.setSelected(true);
          jCheckBoxLun2.setSelected(true);
          jCheckBoxMar2.setSelected(true);
          jCheckBoxMer2.setSelected(true);
          jCheckBoxJeu2.setSelected(true);
          jCheckBoxVen2.setSelected(true);
 
        } else {
          jCheckBoxLun1.setSelected(false);
          jCheckBoxMar1.setSelected(false);
          jCheckBoxMer1.setSelected(false);
          jCheckBoxJeu1.setSelected(false);
          jCheckBoxVen1.setSelected(false);
          jCheckBoxLun2.setSelected(false);
          jCheckBoxMar2.setSelected(false);
          jCheckBoxMer2.setSelected(false);
          jCheckBoxJeu2.setSelected(false);
          jCheckBoxVen2.setSelected(false);
 
        }
    //}
 
    }//GEN-LAST:event_jCboPcActivityFocusLost
 
    private void jCheckBoxPostposeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxPostposeActionPerformed
        if (jCheckBoxPostpose.isSelected()){
        jDateChooserPostposeFin.setVisible(true);
        jDateChooserPostposeDebut.setVisible(true);
        }
        else {
        jDateChooserPostposeFin.setVisible(false);
        jDateChooserPostposeDebut.setVisible(false);
        }
    }//GEN-LAST:event_jCheckBoxPostposeActionPerformed
 
@SuppressWarnings("empty-statement")
 
    private void jCboFiliationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCboFiliationActionPerformed
 
        String y = String.valueOf(jCboFiliation.getSelectedItem());
 
        if (y.equals("<None>")) {
 
          jTextNom_Parent.setVisible(false);
        } else 
 
        {
          jTextNom_Parent.setVisible(true);       
 
 
 
      }          // TODO add your handling code here:
    }//GEN-LAST:event_jCboFiliationActionPerformed
 
 
/**
     * @param args the command line arguments
     */
 
 
    public static void main(String args[]) {
 
        //java.awt.EventQueue.invokeLater(new Runnable() {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
 
 
 
        /* Create and display the form */
        //java.awt.EventQueue.invokeLater(new Runnable() {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    new AddDecisionsJFrame1().setVisible(true);
                } catch (SQLException ex) {
                    Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(Level.SEVERE, null, ex);
                }
 
 
            }
 
                   public void actionPerformed(ActionEvent e) {
                       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                   }
        });
}
 
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // Generated using JFormDesigner non-commercial license
    private JLabel jLabel1;
    private JButton CmdSave;
    private JLabel jLabel2;
    private JTextField TxtDecId;
    private JLabel jLabel3;
    private JLabel jLabel4;
    private JTextField TxtNumero;
    private JLabel jLabel5;
    private JLabel jLabel6;
    private JLabel jLabel7;
    private JTextField jTxtMatr;
    private JLabel jLabel8;
    private JLabel jLabel9;
    private JCheckBox jCheckBoxRefus;
    private JLabel jLabel10;
    private JCheckBox jCheckBox3;
    private JCheckBox jCheckBoxPostpose;
    private JLabel jLabel12;
    private JComboBox<String> jCboPcActivity;
    private JComboBox<String> jCboTypeAbsence;
    private JCheckBox jCheckBoxVen1;
    private JTextField TxtId;
    private JDateChooser jDateChooserDateDebut;
    private JDateChooser jDateChooserDateFin;
    private JCheckBox jCheckBoxLun1;
    private JCheckBox jCheckBoxMar1;
    private JCheckBox jCheckBoxMer1;
    private JCheckBox jCheckBoxJeu1;
    private JCheckBox jCheckBoxVen2;
    private JCheckBox jCheckBoxLun2;
    private JCheckBox jCheckBoxMar2;
    private JCheckBox jCheckBoxMer2;
    private JCheckBox jCheckBoxJeu2;
    private JScrollPane jScrollPane1;
    private JTextArea jTextAreaRemarques;
    private JLabel jLabel11;
    private JComboBox<String> jCboFiliation;
    private JTextField jTextNom_Parent;
    private JDateChooser jDateChooserDateDec;
    private JDateChooser jDateChooserPostposeDebut;
    private JDateChooser jDateChooserPostposeFin;
    private JTextField jTxtNomPrenom;
    // End of variables declaration//GEN-END:variables
 
    private void jDateChooserPostposeDebutPropertyChange(PropertyChangeEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
 
}
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
ant -f C:\\Users\\habiler\\Desktop\\decisions_T1 -Dnb.internal.action.name=rebuild clean jar
init:
deps-clean:
Updating property file: C:\Users\habiler\Desktop\decisions_T1\build\built-clean.properties
Deleting directory C:\Users\habiler\Desktop\decisions_T1\build
clean:
init:
deps-jar:
Created dir: C:\Users\habiler\Desktop\decisions_T1\build
Updating property file: C:\Users\habiler\Desktop\decisions_T1\build\built-jar.properties
Created dir: C:\Users\habiler\Desktop\decisions_T1\build\classes
Created dir: C:\Users\habiler\Desktop\decisions_T1\build\empty
Created dir: C:\Users\habiler\Desktop\decisions_T1\build\generated-sources\ap-source-output
Compiling 12 source files to C:\Users\habiler\Desktop\decisions_T1\build\classes
C:\Users\habiler\Desktop\decisions_T1\src\decisions\AddDecisionsJFrame1.java:333: error: unreported exception SQLException; must be caught or declared to be thrown
                jTxtMatrFocusLost(e);
1 error
C:\Users\habiler\Desktop\decisions_T1\nbproject\build-impl.xml:955: The following error occurred while executing this line:
C:\Users\habiler\Desktop\decisions_T1\nbproject\build-impl.xml:295: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 2 seconds)