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

JDBC Java Discussion :

NetBeans ne m'affiche pas le contenu de ma table : problème ODBC


Sujet :

JDBC Java

  1. #121
    Modérateur

    Homme Profil pro
    Développeur java, access, sql server
    Inscrit en
    Octobre 2005
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur java, access, sql server
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 711
    Points : 4 797
    Points
    4 797
    Par défaut
    Ce n'est pas étonnant puisque la boîte de dialogue est très probablement modale.
    Tu n'accèdes à rien tant qu'elle n'est pas fermée.
    Labor improbus omnia vincit un travail acharné vient à bout de tout - Ambroise Paré (1510-1590)

    Consulter sans modération la FAQ ainsi que les bons ouvrages : http://jmdoudoux.developpez.com/cours/developpons/java/

  2. #122
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    Ah non mais même sans la petite fenêtre Oui/Non ca ne se ferme pas !
    Par contre je peux naviguer entre les différents onglets !

  3. #123
    Modérateur

    Homme Profil pro
    Développeur java, access, sql server
    Inscrit en
    Octobre 2005
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur java, access, sql server
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 711
    Points : 4 797
    Points
    4 797
    Par défaut
    Et à part les messages d'erreurs Have no FileObject for ... tu n'as pas autre chose comme erreur ?
    Labor improbus omnia vincit un travail acharné vient à bout de tout - Ambroise Paré (1510-1590)

    Consulter sans modération la FAQ ainsi que les bons ouvrages : http://jmdoudoux.developpez.com/cours/developpons/java/

  4. #124
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    Avant que je ferme :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    run:
    Thu Oct 06 13:43:23 CEST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    Après avoir essayé de fermé :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    run:
    Thu Oct 06 13:41:29 CEST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    Element suprimé
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at coactivite2.Fenetre$EcouteurFenetre.windowClosing(Fenetre.java:7928)...
    Code en question :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    public void windowClosing(WindowEvent arg0)
            {
                /* Suppression de l'espace réservé dans la base pour l'annexe en cours */ 
                Annexe.deleteAnnexeEnCours(Integer.parseInt(jTextFieldNumAnnexe.getText()));
                try
                {
                    Connexion.con.close();
                }
                catch (SQLException ex)
                {
                    Logger.getLogger(Fenetre.class.getName()).log(Level.SEVERE, null, ex);
                }
                dispose();
            }

  5. #125
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    Ce qui est étonnant c'est qu'il n'ouvre pas et ferme la connexion uniquement durant une requête mais durant toute l'ouverture de l'application !!!

  6. #126
    Modérateur

    Homme Profil pro
    Développeur java, access, sql server
    Inscrit en
    Octobre 2005
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur java, access, sql server
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 711
    Points : 4 797
    Points
    4 797
    Par défaut
    En principe on ne fait pas comme ça.
    On ouvre la connexion au moment de la requête et on la ferme juste après.

    Avec Access on pouvait se le permettre car ce n'était qu'un fichier.
    Là on a un vrai serveur qui peut couper la connexion au bout d'un certain temps.

    Par ailleurs, pour le message "You have an error in your SQL syntax;"
    cela peut venir de la façon dont les requêtes sont écrites dans le code Java.
    En Access on pouvait se passer du ";" à la fin du code SQL ce qui n'est pas le cas en MySql
    Labor improbus omnia vincit un travail acharné vient à bout de tout - Ambroise Paré (1510-1590)

    Consulter sans modération la FAQ ainsi que les bons ouvrages : http://jmdoudoux.developpez.com/cours/developpons/java/

  7. #127
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    Bon laissons ce "détail" de connexion de coté pour le moment (même s'il faudra s'y atteler car ca risque de généré des problèmes une fois en prod...).

    Je n'arrive pas à cibler le problème quant à la création d'annexe...
    J'ai l'impression que l'ensemble du code est parcouru même s'il n'est pas exécuté (pas nécessaire à l'ouverture de l'application par exemple).
    Ce qui me pose donc un problème pour identifier le problème car en mettant mon arrêt, je parse toute l'application à l'ouverture alors que je n'ai même pas encore essayer de créer une annexe .........

  8. #128
    Modérateur

    Homme Profil pro
    Développeur java, access, sql server
    Inscrit en
    Octobre 2005
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur java, access, sql server
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 711
    Points : 4 797
    Points
    4 797
    Par défaut
    Citation Envoyé par Spiicky Voir le message
    J'ai l'impression que l'ensemble du code est parcouru même s'il n'est pas exécuté (pas nécessaire à l'ouverture de l'application par exemple).
    Je n'ai pas compris.

    Mais si tu mets un point d'arrêt, cette fois-ci avant la boîte de dialogue et que tu lances l'application avec Ctrl+F5
    elle devrait s’arrêter avant la boîte non ?
    Labor improbus omnia vincit un travail acharné vient à bout de tout - Ambroise Paré (1510-1590)

    Consulter sans modération la FAQ ainsi que les bons ouvrages : http://jmdoudoux.developpez.com/cours/developpons/java/

  9. #129
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    Premier point : En commentant les instruction problématique, cela fonctionne sans "accro" mais la connexion reste ouverte...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
            public void windowClosing(WindowEvent arg0)
            {
                /* Suppression de l'espace réservé dans la base pour l'annexe en cours */ 
                Annexe.deleteAnnexeEnCours(Integer.parseInt(jTextFieldNumAnnexe.getText()));
                //try
                //{
                    //Connexion.con.close();
                //} 
                //catch (SQLException ex)
                //{
                    //Logger.getLogger(Fenetre.class.getName()).log(Level.SEVERE, null, ex);
                //}
                dispose();
            }
    Faudrait donc comprendre pourquoi cette "Connexion.con.close();" pose problème.
    Pour rappel, j'ai dû renommer (dans connexion()), Connexion con par Connexion conn
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     String pilote = "com.mysql.jdbc.Driver";
                Class.forName(pilote);
     
                //System.out.println(System.getProperty("user.name"));
     
                Connection conn = DriverManager.getConnection("jdbc:mysql://xxx/coactivitenew","xxx","xxx");
                //System.out.println("getConnection récupérée avec succès");
     
                stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
                //System.out.println("Statement créé avec succès");
     
                java.util.Properties prop = new java.util.Properties();
                prop.put("charSet", "ISO-8859-1");
                conn.setClientInfo(prop);
    Si je modifie de l'autre coté (dans Fenetre.java) il ne connait pas conn...

    Concernant mon point d'arrêt, je peux le mettre oui, à l'ouverture de l'application, il va s'arrêter dessus alors que je n'ai pas encore appelé creerAnnexe()...

  10. #130
    Modérateur

    Homme Profil pro
    Développeur java, access, sql server
    Inscrit en
    Octobre 2005
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur java, access, sql server
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 711
    Points : 4 797
    Points
    4 797
    Par défaut
    cela veut dire que la connexion était placée dans une variable publique "con" ou "conn" accessible depuis l'extérieur de la classe ?
    et non pas avec accès contrôlé par get / set ?

    Et part hasard la variable ne serait pas statique ?
    Labor improbus omnia vincit un travail acharné vient à bout de tout - Ambroise Paré (1510-1590)

    Consulter sans modération la FAQ ainsi que les bons ouvrages : http://jmdoudoux.developpez.com/cours/developpons/java/

  11. #131
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    Tu m'as mis sur la bonne piste !
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    public class Connexion {
    
        public static Connection conn;
    Le con était à corriger ici effectivement (et en statique right).

    Ensuite, il était redéclaré dans Connexion() :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Connection conn = DriverManager.getConnection("jdbc:mysql://xxx/coactivitenew","xxx","xxx");
    Maintenant que ceci est corrigé, l'application se ferme correctement !!!

    Mais (l'éternel "Mais"...) je n'arrive toujours pas à créer une annexe !

  12. #132
    Modérateur

    Homme Profil pro
    Développeur java, access, sql server
    Inscrit en
    Octobre 2005
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur java, access, sql server
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 711
    Points : 4 797
    Points
    4 797
    Par défaut
    Citation Envoyé par Spiicky Voir le message
    Mais (l'éternel "Mais"...) je n'arrive toujours pas à créer une annexe !
    Eh oui, il faut détruire Carthage !
    On repart donc sur le point d'arrêt ... Ctrl + F5 ... etc
    Labor improbus omnia vincit un travail acharné vient à bout de tout - Ambroise Paré (1510-1590)

    Consulter sans modération la FAQ ainsi que les bons ouvrages : http://jmdoudoux.developpez.com/cours/developpons/java/

  13. #133
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    Bon, je pense que là, une optimisation du code S'IMPOSE !
    Voici le code exécuté à la suite du click sur le BTN créer annexe :
    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
        @SuppressWarnings({"empty-statement", "static-access"})
        private void jButtonCreerAnnexeActionPerformed(java.awt.event.ActionEvent evt) {                                                   
            Color bleu = new Color(204,255,204);
            Color rouge = new Color(250, 70, 70);
            boolean nonValide = false;
     
            /*Verification du champs NumAnnexe*/
            if(jTextFieldNumAnnexe.getText().isEmpty())
            {
                jTextFieldNumAnnexe.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldNumAnnexe.setBackground(Color.WHITE);
            }
     
             /*Verification du champs MatriculeCharge*/
            if(jTextFieldMatriculeCharge.getText().isEmpty())
            {
                jTextFieldMatriculeCharge.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldMatriculeCharge.setBackground(Color.WHITE);
            }
     
             /*Verification du champs TelCharge*/
            if(jTextFieldTelCharge.getText().isEmpty())
            {
                jTextFieldTelCharge.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldTelCharge.setBackground(Color.WHITE);
            }
     
            /*Verification du champs DateCreation*/
            if(jFormattedTextFieldDateCreation.getText().isEmpty())
            {
                jFormattedTextFieldDateCreation.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jFormattedTextFieldDateCreation.setBackground(Color.WHITE);
            }
     
            /*Verification du champs Societe*/
            if(jComboBoxSociete.getSelectedItem()==null)
            {
                jComboBoxSociete.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jComboBoxSociete.setBackground(Color.WHITE);
            }
     
            /*Verification du champs chef chantier*/
            if(jComboBoxCC.getSelectedItem()==null)
            {
                jComboBoxCC.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jComboBoxCC.setBackground(Color.WHITE);
            }
     
            /*Verification du champs TelChefChantier*/
            if(jTextFieldTelCC.getText().isEmpty())
            {
                jTextFieldTelCC.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldTelCC.setBackground(Color.WHITE);
            }
     
            /*Verification du champs Activite*/
            if(jTextFieldActivite.getText().isEmpty())
            {
                jTextFieldActivite.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldActivite.setBackground(Color.WHITE);
            }
     
            /*Verification du champs Risque1*/
            if(jTextFieldRisque1.getText().isEmpty())
            {
                jTextFieldRisque1.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldRisque1.setBackground(Color.WHITE);
            }
            /*Verification du champs Risque2*/
            if(jTextFieldRisque2.getText().isEmpty())
            {
                jTextFieldRisque2.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldRisque2.setBackground(Color.WHITE);
            }
            /*Verification du champs Risque3*/
            if(jTextFieldRisque3.getText().isEmpty())
            {
                jTextFieldRisque3.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldRisque3.setBackground(Color.WHITE);
            }
     
            /*Verification du champs Prevention1*/
            if(jTextFieldPrevention1.getText().isEmpty())
            {
                jTextFieldPrevention1.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldPrevention1.setBackground(Color.WHITE);
            }
            /*Verification du champs Prevention2*/
            if(jTextFieldPrevention2.getText().isEmpty())
            {
                jTextFieldPrevention2.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldPrevention2.setBackground(Color.WHITE);
            }
            /*Verification du champs Prevention3*/
            if(jTextFieldPrevention3.getText().isEmpty())
            {
                jTextFieldPrevention3.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldPrevention3.setBackground(Color.WHITE);
            }
     
            /*Verification du champs DateDeb*/
            if(jFormattedTextFieldDateDeb.getText().isEmpty())
            {
                jFormattedTextFieldDateDeb.setBackground(rouge);
               nonValide = true;
            }
            else
            {
                jFormattedTextFieldDateDeb.setBackground(Color.WHITE);
            }
     
            /*Verification du champs DateFin*/
            if(jFormattedTextFieldDateFin.getText().isEmpty())
            {
                jFormattedTextFieldDateFin.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jFormattedTextFieldDateFin.setBackground(Color.WHITE);
            }
     
            /*Verification du champs Installation*/
            if(jComboBoxInstallation.getSelectedItem()==null)
            {
                jComboBoxInstallation.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jComboBoxInstallation.setBackground(Color.WHITE);
            }
     
            /*Verification du champs Zone*/
            if(jComboBoxZone.getSelectedItem()==null)
            {
                jComboBoxZone.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jComboBoxZone.setBackground(Color.WHITE);
            }
     
            /*Verification du champs Effectif*/
            if(jTextFieldEffectif.getText().isEmpty())
            {
                jTextFieldEffectif.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextFieldEffectif.setBackground(Color.WHITE);
            }
     
            /*Verification du champs NatureIntervention*/
            if(jTextAreaNatureIntervention.getText().isEmpty())
            {
                jTextAreaNatureIntervention.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jTextAreaNatureIntervention.setBackground(Color.WHITE);
            }
     
     
            if(jRadioButton1422.isSelected()==false && jRadioButton614.isSelected()==false && jRadioButton716.isSelected()==false && jRadioButtonNuit.isSelected()==false && jRadioButtonWeek.isSelected()==false)
            {
                jRadioButton1422.setBackground(rouge);
                jRadioButton614.setBackground(rouge);
                jRadioButton716.setBackground(rouge);
                jRadioButtonNuit.setBackground(rouge);
                jRadioButtonWeek.setBackground(rouge);
                nonValide = true;
            }
            else
            {
                jRadioButton1422.setBackground(bleu);
                jRadioButton614.setBackground(bleu);
                jRadioButton716.setBackground(bleu);
                jRadioButtonNuit.setBackground(bleu);
                jRadioButtonWeek.setBackground(bleu);
            }
     
            if(jRadioButtonConsignationOui.isSelected())
            {
                if(jTextFieldValiditeConsignation.getText().isEmpty())
                {
                    jTextFieldValiditeConsignation.setBackground(rouge);
                    nonValide = true;
                }
     
                if(jTextFieldDelivrerConsignation.getText().isEmpty())
                {
                    jTextFieldDelivrerConsignation.setBackground(rouge);
                    nonValide = true;
                }
            }
            else
            {
                jTextFieldValiditeConsignation.setBackground(Color.WHITE);
                jTextFieldDelivrerConsignation.setBackground(Color.WHITE);
            }
     
            if(jRadioButtonFeuOui.isSelected())
            {
                if(jTextFieldValiditeFeu.getText().isEmpty())
                {
                    jTextFieldValiditeFeu.setBackground(rouge);
                    nonValide = true;
                }
     
                if(jTextFieldDelivrerFeu.getText().isEmpty())
                {
                    jTextFieldDelivrerFeu.setBackground(rouge);
                    nonValide = true;
                }
            }
            else
            {
                jTextFieldValiditeFeu.setBackground(Color.WHITE);
                jTextFieldDelivrerFeu.setBackground(Color.WHITE);
            }
            if(nonValide == true)
            {
                jDialogErreurAjoutAnnexe.setVisible(true);
            }
    }
    On devrait commencer par optimiser ce code avant toutes autres interventions ! C'est tellement horrible à lire ...
    T'opterais pour un switch/case ?

  14. #134
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    On peut faire un truc du genre ?
    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
     
    array() = (
    jTextFieldNumAnnexe
    , jTextFieldMatriculeCharge
    , jTextFieldTelCharge
    , jFormattedTextFieldDateCreation
    , ...
    ) 
     
    foreach (elem as array())
       if (elem.getText().isEmpty())
       {
          elem.setBackground(rouge);
          nonValide = true;
       }
       else
       {
          elem.setBackground(Color.WHITE);
       }
    ps : “Le travail acharné paie demain. La paresse est récompensée aujourd’hui.”

  15. #135
    Modérateur

    Homme Profil pro
    Développeur java, access, sql server
    Inscrit en
    Octobre 2005
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur java, access, sql server
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 711
    Points : 4 797
    Points
    4 797
    Par défaut
    On peut faire un truc du genre
    Absolument !!!
    Tu peux utiliser ArrayList pour cela.

    “Le travail acharné paie demain. La paresse est récompensée aujourd’hui.”
    Pas d'accord : ton travail - acharné - sur le sujet qui nous occupe le prouve.
    Labor improbus omnia vincit un travail acharné vient à bout de tout - Ambroise Paré (1510-1590)

    Consulter sans modération la FAQ ainsi que les bons ouvrages : http://jmdoudoux.developpez.com/cours/developpons/java/

  16. #136
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    Petite erreure sur la déclaration de mon ArrayList:
    ==> EDIT : Résolu avec : import java.util.ArrayList;
    Nom : Sans titre.jpg
Affichages : 176
Taille : 269,6 Ko

    Sinon, voici le code pondu , ca te semble bon ?
    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
            ArrayList TextField = new ArrayList();
                TextField.add("jTextFieldNumAnnexe");
                TextField.add("jTextFieldMatriculeCharge");
                TextField.add("jTextFieldTelCharge");
                TextField.add("jFormattedTextFieldDateCreation");
                TextField.add("jTextFieldTelCC");
                TextField.add("jTextFieldActivite");
                TextField.add("jTextFieldRisque1");
                TextField.add("jTextFieldRisque2");
                TextField.add("jTextFieldRisque3");
                TextField.add("jTextFieldPrevention1");
                TextField.add("jTextFieldPrevention2");
                TextField.add("jTextFieldPrevention3");
                TextField.add("jFormattedTextFieldDateDeb");
                TextField.add("jFormattedTextFieldDateFin");
                TextField.add("jTextFieldEffectif");
                TextField.add("jTextAreaNatureIntervention");
                TextField.add("jFormattedTextFieldDateFin");
                TextField.add("jFormattedTextFieldDateFin");
                TextField.add("jFormattedTextFieldDateFin");
                TextField.add("jFormattedTextFieldDateFin");
            for(int i = 0; i < TextField.size(); i++)
            {
                if(TextField.get(i).getText().isEmpty())
                {
                    TextField.get(i).setBackground(rouge);
                    nonValide = true;
                }
                else
                {
                    TextField.get(i).setBackground(Color.WHITE);
                }
            }
    Et pour l'autre type de condition :
    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
    ArrayList SelectedItem = new ArrayList();
                SelectedItem.add("jComboBoxSociete");
                SelectedItem.add("jComboBoxCC");
                SelectedItem.add("jComboBoxInstallation");
                SelectedItem.add("jComboBoxZone");
                SelectedItem.add("jComboBoxSociete");
                SelectedItem.add("jComboBoxSociete");
            for(int i = 0; i < SelectedItem.size(); i++)
            {
                if(SelectedItem.get(i).getSelectedItem()==null)
                {
                    SelectedItem.get(i).setBackground(rouge);
                    nonValide = true;
                }
                else
                {
                    SelectedItem.get(i).setBackground(Color.WHITE);
                }
            }

  17. #137
    Modérateur

    Homme Profil pro
    Développeur java, access, sql server
    Inscrit en
    Octobre 2005
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur java, access, sql server
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 711
    Points : 4 797
    Points
    4 797
    Par défaut
    pas bon du tout !

    Tu as fait un tableau de noms !
    Tu ne peux pas faire TextField.get(i).getText().isEmpty() avec ce tableau car TextField.get(i) va pointer sur une chaîne de caractères et non pas sur un objet JTextField


    Ton tableau doit être un tableau d'objets JTextField :
    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
            ArrayList TextField = new ArrayList<JTextField>();
                TextField.add(jTextFieldNumAnnexe);
                TextField.add(jTextFieldMatriculeCharge);
                TextField.add(jTextFieldTelCharge);
                TextField.add(jFormattedTextFieldDateCreation);
                TextField.add(jTextFieldTelCC);
                TextField.add(jTextFieldActivite);
                TextField.add(jTextFieldRisque1);
                TextField.add(jTextFieldRisque2);
                TextField.add(jTextFieldRisque3);
                TextField.add(jTextFieldPrevention1);
                TextField.add(jTextFieldPrevention2);
                TextField.add(jTextFieldPrevention3);
                TextField.add(jFormattedTextFieldDateDeb);
                TextField.add(jFormattedTextFieldDateFin);
                TextField.add(jTextFieldEffectif);
                TextField.add(jTextAreaNatureIntervention);
                TextField.add(jFormattedTextFieldDateFin);
                TextField.add(jFormattedTextFieldDateFin);
                TextField.add(jFormattedTextFieldDateFin);
                TextField.add(jFormattedTextFieldDateFin);
            for(int i = 0; i < TextField.size(); i++)
            {
                if(TextField.get(i).getText().isEmpty())
                {
                    TextField.get(i).setBackground(rouge);
                    nonValide = true;
                }
                else
                {
                    TextField.get(i).setBackground(Color.WHITE);
                }
            }
    ATTENTION à bien retirer les guillemets !

    et faire sur le même principe avec l'autre tableau
    Labor improbus omnia vincit un travail acharné vient à bout de tout - Ambroise Paré (1510-1590)

    Consulter sans modération la FAQ ainsi que les bons ouvrages : http://jmdoudoux.developpez.com/cours/developpons/java/

  18. #138
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    Ah ouais mince, je n'ai pas été très attentif

    J'ai encore dû importer des libs, mais je ne comprend pas comment cela fonctionnait avant ... c'est vraiment bizarre

    On poursuit tranquillement avec une nouvelle erreur :
    Nom : Sans titre.jpg
Affichages : 176
Taille : 55,8 Ko
    J'ai l'impression de getText() n'est plus accessible à l’intérieur du for :/

    Autre petit soucis, au niveau de la connexion, tu me parlais de faire disparaître (comme par magie ) les Vector ?
    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
    /* Méthode affichant les résultat d'une requête dans un jTable avec création de ligne automatique */
        public static void AffichageAnnexe(String query, JTable table)
        {
            try
            {
                DefaultTableModel modele = (DefaultTableModel) table.getModel();
                Vector<Vector<String>> data = null;
                Connexion.res = Connexion.stmt.executeQuery(query);
                int i = 0;
                Utilitaire.centrerTable(table);
    
                while(Connexion.res.next())
                {
                    modele.addRow(data);
                    table.setValueAt(Connexion.res.getInt(1),i,0);
    ...

  19. #139
    Modérateur

    Homme Profil pro
    Développeur java, access, sql server
    Inscrit en
    Octobre 2005
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur java, access, sql server
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 711
    Points : 4 797
    Points
    4 797
    Par défaut
    Ah mince, j'ai oublié de spécifier le tableau :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ArrayList<JTextField> TextField = new ArrayList<JTextField>();
    Ceci a pour but de spécifier que le tableau contient obligatoirement des JTextField.

    Pour l'instant, laisse les Vectors de côté.
    Labor improbus omnia vincit un travail acharné vient à bout de tout - Ambroise Paré (1510-1590)

    Consulter sans modération la FAQ ainsi que les bons ouvrages : http://jmdoudoux.developpez.com/cours/developpons/java/

  20. #140
    Nouveau membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2015
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2015
    Messages : 340
    Points : 31
    Points
    31
    Par défaut
    Ah oui, c'est beaucoup mieux
    Je rencontre un soucis avec :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    ArrayList<JTextField> TextField = new ArrayList<JTextField>();
                TextField.add(jTextFieldNumAnnexe);
                TextField.add(jTextAreaNatureIntervention);
    J'ai essayé comme ca sans succès :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     ArrayList<jTextArea> TextArea = new ArrayList<jTextArea>();
    C'est une textArea, je suis censé la manipulé au même titre que les autres non ?
    ==> EDIT : Corrigé, ne manquait que l'import de JTextArea.

    Par contre la même manipulation ne fonctionne pas pour les ComboBox ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     ArrayList<JComboBox> SelectedItem = new ArrayList<JComboBox>();
                SelectedItem.add(jComboBoxSociete);
                SelectedItem.add(jComboBoxCC);

+ Répondre à la discussion
Cette discussion est résolue.
Page 7 sur 31 PremièrePremière ... 3456789101117 ... DernièreDernière

Discussions similaires

  1. ListView qui change de taille mais n'affiche pas le contenu d'une ObservableCollection
    Par Atellane dans le forum Windows Presentation Foundation
    Réponses: 4
    Dernier message: 14/08/2014, 10h46
  2. DataGrid n'affiche pas le contenu de certaines colonnes d'un Datatable
    Par alucia dans le forum Windows Presentation Foundation
    Réponses: 3
    Dernier message: 20/09/2013, 13h39
  3. .load qui n'affiche pas le contenu de la page
    Par tonydu91 dans le forum jQuery
    Réponses: 4
    Dernier message: 06/04/2013, 23h58
  4. [SimpleXML] Problème avec simpleXML : il n'affiche pas le contenu de mon élément
    Par ploxien dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 05/05/2007, 19h43
  5. GUI Java par netbeans - ne s'affiche pas
    Par G_angel dans le forum AWT/Swing
    Réponses: 4
    Dernier message: 31/01/2007, 11h38

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