IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Java Discussion :

Affichage Jpanel ds jFrame


Sujet :

Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    470
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2009
    Messages : 470
    Par défaut Affichage Jpanel ds jFrame
    Bonsoir a tous,

    J'essaie d'afficher un jpanel daans mon jFrame mais il ne s affiche pas?

    Quelqu'un peut-il m aider?

    MErci d avanc e

    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
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
     
    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 java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.table.DefaultTableModel;
     
     
    public class AddDecisionsJFrame1 extends JFrame {
     
    Connection conn =null;
    ResultSet rs = null;
    PreparedStatement ps = null;
     private boolean DEBUG = false;
     
       private JPanel p = new JPanel();//ton panel
        private JLabel LabTab[] = {new JLabel(),new JLabel(),new JLabel(),new JLabel(),new JLabel(),new JLabel(),new JLabel(),new JLabel(),new JLabel(),new JLabel()};//un tableau contenant les JLabel et j'en met 10
        private int posy = 10;
        private int labsize = 11;//taille du texte
     
    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 String s;
        private static int entier = 1;
     
         public String Maclasse(){
            s="Bibo";
            s+=" n°"+entier;
            return s;
        }
     public String getmessage(){
            entier++;
            System.out.println("s =" +s);
            return s;
        }
     
    public String Fenetre(){
        setSize(150,200);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
        setContentPane(p);
        p.setLayout(null);//pour positionner les Labels où l'on veut
         for(JLabel l : LabTab){//on lit le tableau et on s'occupe du texte contenu dans les Labels
             String s = new Maclasse().getmessage();
             l = new JLabel(s);
             l.setFont(new Font(Font.SANS_SERIF,Font.ROMAN_BASELINE,labsize));
             l.setForeground(Color.RED);
             p.add(l);
           sauterligne(l);
        }
         return s;
    }
     
    private void sauterligne(JLabel l){
       l.setBounds(10,posy,100,labsize); //on positionne le label, (x,y,longueur max x, hauteur max y)
       posy+=15;
    } 
     @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
        }
     
        private void jTxtMatrFocusLost(){
                  PreparedStatement ps1;
                    Connection conn = Connect.ConnectDB();
     
                try {   
                    String SQL1 = "SELECT * FROM Signaletique where Matricule = ?";
     
                        affiche("hhh 1") ;   
                        ps1 = conn.prepareStatement(SQL1); 
                        ps1.setString(1,jTxtMatr.getText());  
                        ResultSet rs1 = ps1.executeQuery();
                        affiche("Matr :"+jTxtMatr.getText()) ;
     
     
                while ( rs1.next()) {
     
                jTxtNomPrenom.setText(rs1.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){
     
            JOptionPane.showMessageDialog(null, e);
        }         
        }
        private void toggleButton1ActionPerformed(ActionEvent e) {
            // TODO add your code here
                 jLabel3.setText("Matricule No ");
        }
        private void toggleButton2ActionPerformed(ActionEvent e) {
            // TODO add your code here
                 jLabel3.setText("Stamnummer");
        }
     
     
    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);
        }
     
    }
     
     
        @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();
            desktopPane1 = new JDesktopPane();
            toggleBtnFr = new JToggleButton();
            toggleButton3 = new JToggleButton();
     
            //======== this ========
            setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            setTitle("A0");
            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(25, 70, 95, 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(455, 430), CmdSave.getPreferredSize()));
     
            //---- jLabel2 ----
            jLabel2.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel2.setText("DecId");
            contentPane.add(jLabel2);
            jLabel2.setBounds(25, 90, jLabel2.getPreferredSize().width, 18);
            contentPane.add(TxtDecId);
            TxtDecId.setBounds(140, 90, 91, TxtDecId.getPreferredSize().height);
     
            //---- jLabel3 ----
            jLabel3.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel3.setText("Matricule");
            contentPane.add(jLabel3);
            jLabel3.setBounds(new Rectangle(new Point(20, 40), jLabel3.getPreferredSize()));
     
            //---- 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();
                }
            });
            contentPane.add(jTxtMatr);
            jTxtMatr.setBounds(140, 35, 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, 65, 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(150, 390, 245, jScrollPane1.getPreferredSize().height);
     
            //---- 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()));
     
            //---- jTxtNomPrenom ----
            jTxtNomPrenom.setBackground(UIManager.getColor("Button.background"));
            jTxtNomPrenom.setEditable(false);
            jTxtNomPrenom.setBorder(null);
            contentPane.add(jTxtNomPrenom);
            jTxtNomPrenom.setBounds(240, 35, 230, 20);
            contentPane.add(desktopPane1);
            desktopPane1.setBounds(new Rectangle(new Point(1090, 280), desktopPane1.getPreferredSize()));
     
            //---- toggleBtnFr ----
            toggleBtnFr.setText("Fr");
            toggleBtnFr.setIcon(new ImageIcon(getClass().getResource("/decisions/french.png")));
            toggleBtnFr.setBorder(null);
            toggleBtnFr.addActionListener(e -> toggleButton2ActionPerformed(e));
            contentPane.add(toggleBtnFr);
            toggleBtnFr.setBounds(new Rectangle(new Point(70, 0), toggleBtnFr.getPreferredSize()));
     
            //---- toggleButton3 ----
            toggleButton3.setText("Nl");
            toggleButton3.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/dutch.png")));
            toggleButton3.setIcon(new ImageIcon(getClass().getResource("/decisions/dutch.png")));
            toggleButton3.setBorder(null);
            contentPane.add(toggleButton3);
            toggleButton3.setBounds(new Rectangle(new Point(120, 0), toggleButton3.getPreferredSize()));
     
            { // 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(3, jTxtMatr.getText());               
                       // affiche ("Matr : " +jTxtMatr);   
     
        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
     
     
        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);
                //       new Fenetre().setVisible(true);
                    } catch (SQLException ex) {
                        Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(Level.SEVERE, null, ex);
                    }
     
     
                }
     
     
            });
    }
     
        // 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;
        private JDesktopPane desktopPane1;
        private JToggleButton toggleBtnFr;
        private JToggleButton toggleButton3;
        // 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.
        }
    }

  2. #2
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Octobre 2013
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2013
    Messages : 72
    Par défaut
    Bonsoir

    be lève les // ... comme on dit par ici

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
             public void run() {
                    try {
                        new AddDecisionsJFrame1().setVisible(true);
                //       new Fenetre().setVisible(true);
                    } catch (SQLException ex) {
                        Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(Level.SEVERE, null, ex);
                    }

  3. #3
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Octobre 2013
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2013
    Messages : 72
    Par défaut
    C'est pas prêt de compiler ton histoire, il faudrait déclarer tous les (50) composants utilisés

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
      private void initComponents() {
            jLabel1 = new JLabel();
            CmdSave = new JButton();
            jLabel2 = new JLabel();
            TxtDecId = new JTextField();
            jLabel3 = new JLabel();
            jLabel4 = new JLabel();
    Tu testes pas ton code au fur et à mesure que t'écris?

    Ha oui compris
    // Generated using JFormDesigner non-commercial license

    Alors vu la technique utilisée ... bonsoir!

Discussions similaires

  1. Problème affichage JPanel dans JFrame
    Par Papipen dans le forum Agents de placement/Fenêtres
    Réponses: 2
    Dernier message: 18/06/2009, 20h45
  2. Réponses: 3
    Dernier message: 29/04/2006, 22h06
  3. JPanel dans JFrame non visible au lancement.
    Par PRomu@ld dans le forum Agents de placement/Fenêtres
    Réponses: 16
    Dernier message: 17/03/2006, 08h22
  4. [JFrame] Rafraichir l'affichage d'1 JFrame
    Par tomburn dans le forum Agents de placement/Fenêtres
    Réponses: 4
    Dernier message: 21/04/2005, 11h39
  5. Accélérer l'affichage d'une jframe
    Par debutant java dans le forum Agents de placement/Fenêtres
    Réponses: 5
    Dernier message: 16/04/2005, 12h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo