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

NetBeans Java Discussion :

créer un tableau commun à toutes les méthodes


Sujet :

NetBeans Java

  1. #1
    Membre actif Avatar de stracoma
    Homme Profil pro
    Médecin
    Inscrit en
    Août 2013
    Messages
    413
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : Maroc

    Informations professionnelles :
    Activité : Médecin

    Informations forums :
    Inscription : Août 2013
    Messages : 413
    Points : 229
    Points
    229
    Par défaut créer un tableau commun à toutes les méthodes
    Bonsoir tout le monde;
    j'ai un petit problème que je n'arrive pas à résoudre.
    j'ai une jFrame avec des jlabel et des radiobuton :
    Nom : developper.png
Affichages : 123
Taille : 3,6 Ko

    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
     
    import java.awt.Color;
    import javax.swing.JLabel;
     
     
    public class Form1 extends javax.swing.JFrame {
     
     
        public void activer(JLabel lbl){
            lbl.setForeground(new Color(50, 200, 50));
        }
        public void inactiver(JLabel lbl){
            lbl.setForeground(new Color(200, 50, 50));
        }
     
        public Form1() {
            initComponents();
            this.setSize(265, 200);
            this.setLocation(200, 200);
     
        }
     
     
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
     
            buttonGroup1 = new javax.swing.ButtonGroup();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            jLabel5 = new javax.swing.JLabel();
            jLabel6 = new javax.swing.JLabel();
            jLabel7 = new javax.swing.JLabel();
            jLabel8 = new javax.swing.JLabel();
            rbt_1_3_7 = new javax.swing.JRadioButton();
            rbt_1_2 = new javax.swing.JRadioButton();
            rbt_2_4_6 = new javax.swing.JRadioButton();
            rbt_4_6_7_8 = new javax.swing.JRadioButton();
            rbt_1_6_7 = new javax.swing.JRadioButton();
            rbt_4_5_8 = new javax.swing.JRadioButton();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowOpened(java.awt.event.WindowEvent evt) {
                    formWindowOpened(evt);
                }
            });
            getContentPane().setLayout(null);
     
            jLabel1.setText("jLabel1");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(180, 20, 60, 17);
     
            jLabel2.setText("jLabel2");
            getContentPane().add(jLabel2);
            jLabel2.setBounds(180, 40, 60, 17);
     
            jLabel3.setText("jLabel3");
            getContentPane().add(jLabel3);
            jLabel3.setBounds(180, 60, 60, 17);
     
            jLabel4.setText("jLabel4");
            getContentPane().add(jLabel4);
            jLabel4.setBounds(180, 80, 60, 17);
     
            jLabel5.setText("jLabel5");
            getContentPane().add(jLabel5);
            jLabel5.setBounds(180, 100, 60, 17);
     
            jLabel6.setText("jLabel6");
            getContentPane().add(jLabel6);
            jLabel6.setBounds(180, 120, 60, 17);
     
            jLabel7.setText("jLabel7");
            getContentPane().add(jLabel7);
            jLabel7.setBounds(180, 140, 60, 17);
     
            jLabel8.setText("jLabel8");
            getContentPane().add(jLabel8);
            jLabel8.setBounds(180, 160, 60, 17);
     
            buttonGroup1.add(rbt_1_3_7);
            rbt_1_3_7.setText("rbt_1_3_7");
            rbt_1_3_7.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rbt_1_3_7ActionPerformed(evt);
                }
            });
            getContentPane().add(rbt_1_3_7);
            rbt_1_3_7.setBounds(20, 10, 120, 26);
     
            buttonGroup1.add(rbt_1_2);
            rbt_1_2.setText("rbt_1_2");
            rbt_1_2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rbt_1_2ActionPerformed(evt);
                }
            });
            getContentPane().add(rbt_1_2);
            rbt_1_2.setBounds(20, 40, 120, 26);
     
            buttonGroup1.add(rbt_2_4_6);
            rbt_2_4_6.setText("rbt_2_4_6");
            rbt_2_4_6.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rbt_2_4_6ActionPerformed(evt);
                }
            });
            getContentPane().add(rbt_2_4_6);
            rbt_2_4_6.setBounds(20, 70, 120, 26);
     
            buttonGroup1.add(rbt_4_6_7_8);
            rbt_4_6_7_8.setText("rbt_4_6_7_8");
            getContentPane().add(rbt_4_6_7_8);
            rbt_4_6_7_8.setBounds(20, 100, 120, 26);
     
            buttonGroup1.add(rbt_1_6_7);
            rbt_1_6_7.setText("rbt_1_6_7");
            getContentPane().add(rbt_1_6_7);
            rbt_1_6_7.setBounds(20, 130, 120, 26);
     
            buttonGroup1.add(rbt_4_5_8);
            rbt_4_5_8.setText("rbt_4_5_8");
            getContentPane().add(rbt_4_5_8);
            rbt_4_5_8.setBounds(20, 160, 120, 26);
     
            pack();
        }// </editor-fold>                        
     
        private void formWindowOpened(java.awt.event.WindowEvent evt) {                                  
            JLabel mesLabel[]={jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7,jLabel8};
            for(int i=0;i<8;i++){
                inactiver(mesLabel[i]);
            }
        }                                 
     
        private void rbt_1_3_7ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            JLabel mesLabel[]={jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7,jLabel8};
            for(int i=0;i<8;i++){
                if(i==0 || i==2 || i==6){
                    activer(mesLabel[i]);
                }else{
                    inactiver(mesLabel[i]);
                }
     
            }
        }                                         
     
        private void rbt_1_2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            JLabel mesLabel[]={jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7,jLabel8};
            for(int i=0;i<8;i++){
                if(i==0 || i==1){
                    activer(mesLabel[i]);
                }else{
                    inactiver(mesLabel[i]);
                }
     
            }
        }                                       
     
        private void rbt_2_4_6ActionPerformed(java.awt.event.ActionEvent evt) {                                          
             JLabel mesLabel[]={jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7,jLabel8};
            for(int i=0;i<8;i++){
                if(i==1 || i==3 || i==5){
                    activer(mesLabel[i]);
                }else{
                    inactiver(mesLabel[i]);
                }
     
            }
        }                                         
     
        public static void main(String args[]) {
           //*****************************************
     
           //*****************************************
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Form1().setVisible(true);
                }
            });
        }
     
        // Variables declaration - do not modify                     
        private javax.swing.ButtonGroup buttonGroup1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel7;
        private javax.swing.JLabel jLabel8;
        private javax.swing.JRadioButton rbt_1_2;
        private javax.swing.JRadioButton rbt_1_3_7;
        private javax.swing.JRadioButton rbt_1_6_7;
        private javax.swing.JRadioButton rbt_2_4_6;
        private javax.swing.JRadioButton rbt_4_5_8;
        private javax.swing.JRadioButton rbt_4_6_7_8;
        // End of variables declaration                   
    }
    comment créer un tableau " JLabel mesLabel[]={jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7,jLabel8};" une seule fois sans à devoir le créer pour chaque radiobutton?
    Merci
    J'apprends la programmation pour le plaisir

  2. #2
    Membre averti
    Homme Profil pro
    Architecte technique
    Inscrit en
    Mai 2020
    Messages
    325
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Architecte technique

    Informations forums :
    Inscription : Mai 2020
    Messages : 325
    Points : 436
    Points
    436
    Par défaut
    Bonjour,

    Il faut juste déplacer la ligne qui déclare le tableau.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    public class Form1 extends javax.swing.JFrame {
     
      private final JLabel mesLabel[];
     
      private void initComponents() {
        // ...
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        // ...
        mesLabel = {jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7,jLabel8};
      }
    }
    Etant donné que toutes les utilisations se font dans la même classe, vous aurez accès à mesLabel partout ou c'est nécessaire. Mais il faudra faire attention aux NullPointerException en appelant vos méthodes que lorsque que initComponents() aura été appelé.



    Une solution plus sure serait peut-être d'initialiser ce tableau quand vous le déclarez et de réferencer les JLabel par leurs indexs:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    public class Form1 extends javax.swing.JFrame {
     
      private final JLabel mesLabel[] = {new JLabel("Label 1"), new JLabel("Label 2"), ...}
     
      private void initComponents() {
        // ...
        getContentPane().add(mesLabel[1]); 
        mesLabel[1].setBounds(180, 40, 60, 17);
      }
    }

  3. #3
    Membre actif Avatar de stracoma
    Homme Profil pro
    Médecin
    Inscrit en
    Août 2013
    Messages
    413
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : Maroc

    Informations professionnelles :
    Activité : Médecin

    Informations forums :
    Inscription : Août 2013
    Messages : 413
    Points : 229
    Points
    229
    Par défaut
    Bonsoir
    merci gervais.b pour votre réponse. Je suis débutant, je n'ai pas compris ce que vous vouliez dire.
    j'ai essayé ce code mais sans succès:
    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
    import java.awt.Color;
    import java.awt.HeadlessException;
    import javax.swing.ButtonGroup;
    import javax.swing.JLabel;
    import javax.swing.JRadioButton;
     
     
    public class Form1 extends javax.swing.JFrame {
     
        private final JLabel mesLabel[] = {new JLabel("Label1"), new JLabel("Label2"),new JLabel("Label3"), new JLabel("Label4"),new JLabel("Label5"), new JLabel("Label6"),new JLabel("Label7"), new JLabel("Label8")};
     
         private void initComponents() {
            mesLabel[0]=jLabel1;
            mesLabel[1]=jLabel2;
            mesLabel[2]=jLabel3;
            mesLabel[3]=jLabel4;
            mesLabel[4]=jLabel5;
            mesLabel[5]=jLabel6;
            mesLabel[6]=jLabel7;
            mesLabel[7]=jLabel8;
         }
     
     
        public void activer(JLabel lbl){
            lbl.setForeground(new Color(50, 200, 50));
        }
        public void inactiver(JLabel lbl){
            lbl.setForeground(new Color(200, 50, 50));
        }
     
        public Form1() {
     
     
            initComponents();
            this.setSize(265, 200);
            this.setLocation(200, 200);
     
            this.setSize(265, 200);
            this.setLocation(200, 200);
     
        }
     
     
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
     
            buttonGroup1 = new javax.swing.ButtonGroup();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            jLabel5 = new javax.swing.JLabel();
            jLabel6 = new javax.swing.JLabel();
            jLabel7 = new javax.swing.JLabel();
            jLabel8 = new javax.swing.JLabel();
            rbt_1_3_7 = new javax.swing.JRadioButton();
            rbt_1_2 = new javax.swing.JRadioButton();
            rbt_2_4_6 = new javax.swing.JRadioButton();
            rbt_4_6_7_8 = new javax.swing.JRadioButton();
            rbt_1_6_7 = new javax.swing.JRadioButton();
            rbt_4_5_8 = new javax.swing.JRadioButton();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowOpened(java.awt.event.WindowEvent evt) {
                    formWindowOpened(evt);
                }
            });
            getContentPane().setLayout(null);
     
            jLabel1.setText("jLabel1");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(180, 20, 60, 18);
     
            jLabel2.setText("jLabel2");
            getContentPane().add(jLabel2);
            jLabel2.setBounds(180, 40, 60, 18);
     
            jLabel3.setText("jLabel3");
            getContentPane().add(jLabel3);
            jLabel3.setBounds(180, 60, 60, 18);
     
            jLabel4.setText("jLabel4");
            getContentPane().add(jLabel4);
            jLabel4.setBounds(180, 80, 60, 18);
     
            jLabel5.setText("jLabel5");
            getContentPane().add(jLabel5);
            jLabel5.setBounds(180, 100, 60, 18);
     
            jLabel6.setText("jLabel6");
            getContentPane().add(jLabel6);
            jLabel6.setBounds(180, 120, 60, 18);
     
            jLabel7.setText("jLabel7");
            getContentPane().add(jLabel7);
            jLabel7.setBounds(180, 140, 60, 18);
     
            jLabel8.setText("jLabel8");
            getContentPane().add(jLabel8);
            jLabel8.setBounds(180, 160, 60, 18);
     
            buttonGroup1.add(rbt_1_3_7);
            rbt_1_3_7.setText("rbt_1_3_7");
            rbt_1_3_7.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rbt_1_3_7ActionPerformed(evt);
                }
            });
            getContentPane().add(rbt_1_3_7);
            rbt_1_3_7.setBounds(20, 10, 120, 26);
     
            buttonGroup1.add(rbt_1_2);
            rbt_1_2.setText("rbt_1_2");
            rbt_1_2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rbt_1_2ActionPerformed(evt);
                }
            });
            getContentPane().add(rbt_1_2);
            rbt_1_2.setBounds(20, 40, 120, 26);
     
            buttonGroup1.add(rbt_2_4_6);
            rbt_2_4_6.setText("rbt_2_4_6");
            rbt_2_4_6.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rbt_2_4_6ActionPerformed(evt);
                }
            });
            getContentPane().add(rbt_2_4_6);
            rbt_2_4_6.setBounds(20, 70, 120, 26);
     
            buttonGroup1.add(rbt_4_6_7_8);
            rbt_4_6_7_8.setText("rbt_4_6_7_8");
            rbt_4_6_7_8.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rbt_4_6_7_8ActionPerformed(evt);
                }
            });
            getContentPane().add(rbt_4_6_7_8);
            rbt_4_6_7_8.setBounds(20, 100, 120, 26);
     
            buttonGroup1.add(rbt_1_6_7);
            rbt_1_6_7.setText("rbt_1_6_7");
            rbt_1_6_7.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rbt_1_6_7ActionPerformed(evt);
                }
            });
            getContentPane().add(rbt_1_6_7);
            rbt_1_6_7.setBounds(20, 130, 120, 26);
     
            buttonGroup1.add(rbt_4_5_8);
            rbt_4_5_8.setText("rbt_4_5_8");
            rbt_4_5_8.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rbt_4_5_8ActionPerformed(evt);
                }
            });
            getContentPane().add(rbt_4_5_8);
            rbt_4_5_8.setBounds(20, 160, 120, 26);
     
            pack();
        }// </editor-fold>                        
     
        private void formWindowOpened(java.awt.event.WindowEvent evt) {                                  
          // JLabel mesLabel[]={jLabel0,jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7};
     
            for(int i=0;i<8;i++){
                inactiver(mesLabel[i]);
            }
        }                                 
     
        private void rbt_1_3_7ActionPerformed(java.awt.event.ActionEvent evt) {                                          
     
            //JLabel mesLabel[]={jLabel0,jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7};
            for(int i=0;i<8;i++){
                if(i==0 || i==2 || i==6){
                    activer(mesLabel[i]);
                }else{
                    inactiver(mesLabel[i]);
                }
     
            }
        }                                         
     
        private void rbt_1_2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            //JLabel mesLabel[]={jLabel0,jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7};
            for(int i=0;i<8;i++){
                if(i==0 || i==1){
                    activer(mesLabel[i]);
                }else{
                    inactiver(mesLabel[i]);
                }
     
            }
        }                                       
     
        private void rbt_2_4_6ActionPerformed(java.awt.event.ActionEvent evt) {                                          
               // JLabel mesLabel[]={jLabel0,jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7};        for(int i=0;i<8;i++){
               for(int i=0;i<8;i++){
                if(i==1 || i==3 || i==5){
                    activer(mesLabel[i]);
                }else{
                    inactiver(mesLabel[i]);
                }
     
            }
        }                                         
     
        private void rbt_4_6_7_8ActionPerformed(java.awt.event.ActionEvent evt) {                                            
            //JLabel mesLabel[]={jLabel0,jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7};
            for(int i=0;i<8;i++){
                if(i==6 || i==3 || i==5 || i==7){
                    activer(mesLabel[i]);
                }else{
                    inactiver(mesLabel[i]);
                }
     
            }
        }                                           
     
        private void rbt_1_6_7ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            //JLabel mesLabel[]={jLabel0,jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7};
            for(int i=0;i<8;i++){
                if(i==0 || i==6 || i==5){
                    activer(mesLabel[i]);
                }else{
                    inactiver(mesLabel[i]);
                }
     
            }
        }                                         
     
        private void rbt_4_5_8ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            //JLabel mesLabel[]={jLabel0,jLabel1,jLabel2,jLabel3,jLabel4,jLabel5,jLabel6,jLabel7};
            for(int i=0;i<8;i++){
                if(i==4 || i==3 || i==7){
                    activer(mesLabel[i]);
                }else{
                    inactiver(mesLabel[i]);
                }
     
            }
        }                                         
     
        public static void main(String args[]) {
           //*****************************************
     
           //*****************************************
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Form1().setVisible(true);
                }
            });
        }
     
        // Variables declaration - do not modify                     
        private javax.swing.ButtonGroup buttonGroup1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel7;
        private javax.swing.JLabel jLabel8;
        private javax.swing.JRadioButton rbt_1_2;
        private javax.swing.JRadioButton rbt_1_3_7;
        private javax.swing.JRadioButton rbt_1_6_7;
        private javax.swing.JRadioButton rbt_2_4_6;
        private javax.swing.JRadioButton rbt_4_5_8;
        private javax.swing.JRadioButton rbt_4_6_7_8;
        // End of variables declaration                   
    }
    il donne comme message d'erreur:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    run:
    /home/jonass/.cache/netbeans/8.1/executor-snippets/run.xml:48: 
    Cancelled by user.
    BUILD FAILED (total time: 3 seconds)
    Code XML : 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
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     
    Copyright 2010 Oracle and/or its affiliates. All rights reserved.
     
    Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    Other names may be trademarks of their respective owners.
     
     
    The contents of this file are subject to the terms of either the GNU
    General Public License Version 2 only ("GPL") or the Common
    Development and Distribution License("CDDL") (collectively, the
    "License"). You may not use this file except in compliance with the
    License. You can obtain a copy of the License at
    http://www.netbeans.org/cddl-gplv2.html
    or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    specific language governing permissions and limitations under the
    License.  When distributing the software, include this License Header
    Notice in each file and include the License file at
    nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    particular file as subject to the "Classpath" exception as provided
    by Oracle in the GPL Version 2 section of the License file that
    accompanied this code. If applicable, add the following below the
    License Header, with the fields enclosed by brackets [] replaced by
    your own identifying information:
    "Portions Copyrighted [year] [name of copyright owner]"
     
    Contributor(s):
     
    The Original Software is NetBeans. The Initial Developer of the Original
    Software is Sun Microsystems, Inc. Portions Copyright 2008 Sun
    Microsystems, Inc. All Rights Reserved.
     
    If you wish your version of this file to be governed by only the CDDL
    or only the GPL Version 2, indicate your decision by adding
    "[Contributor] elects to include this software in this distribution
    under the [CDDL or GPL Version 2] license." If you do not indicate a
    single choice of license, a recipient has the option to distribute
    your version of this file under either the CDDL, the GPL Version 2 or
    to extend the choice of license to its licensees as provided above.
    However, if you add GPL Version 2 code and therefore, elected the GPL
    Version 2 license, then the option applies only if the new code is
    made subject to such option by the copyright holder.
    -->
    <project name="{0} (run)" default="run" basedir=".">
        <target name="run">        
            <translate-classpath classpath="${classpath}" targetProperty="classpath-translated" />
            <property name="run.jvmargs" value="" />
            <property name="work.dir" value="${basedir}"/>
            <property name="application.args" value="" />
            <property name="java.failonerror" value="true"/>
            <java classpath="${classpath-translated}" classname="${classname}" dir="${work.dir}" jvm="${platform.java}" fork="true" failonerror="${java.failonerror}">
                <jvmarg value="-Dfile.encoding=${encoding}"/>
                <redirector inputencoding="${encoding}" outputencoding="${encoding}" errorencoding="${encoding}"/>
                <jvmarg line="${run.jvmargs}" />
                <arg line="${application.args}" />
                <syspropertyset>
                    <propertyref prefix="run-sys-prop."/>
                    <mapper from="run-sys-prop.*" to="*" type="glob"/>
                </syspropertyset>
            </java>
        </target>
    </project>
    J'apprends la programmation pour le plaisir

Discussions similaires

  1. [XL-2010] tableau commun à toutes les fonctions
    Par popi33370 dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 24/10/2013, 10h14
  2. Réponses: 3
    Dernier message: 10/02/2012, 12h51
  3. Réponses: 3
    Dernier message: 12/01/2010, 12h13
  4. Réponses: 6
    Dernier message: 27/12/2006, 21h53
  5. [Interface] Appeller toutes les méthodes héritées d'un class
    Par thibaut.d dans le forum Général Java
    Réponses: 4
    Dernier message: 25/01/2005, 08h42

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