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

AWT/Swing Java Discussion :

Renseigner une jComboBox à partir d'une ArrayList


Sujet :

AWT/Swing Java

  1. #1
    Inactif   Avatar de Deallyra
    Profil pro
    Étudiant
    Inscrit en
    Février 2007
    Messages
    1 997
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2007
    Messages : 1 997
    Par défaut Renseigner une jComboBox à partir d'une ArrayList
    Bonsoir,

    Je fais face à un petit problème.

    J'ai implémenté un mini projet me permettant, selon la saisie d'un avion et son vol associé de savoir s'il peut ou non faire le vol, fonction de la distance et du carburant dont il dispose.

    Le fait étant que ce n'est pas friendly user en mode console.

    J'ai donc voulu tester le wysiwyg de NetBeans et me faire une petite interface rapide...

    Mais je bloque dès le départ :/

    J'ai créé une jComboBox... mais je n'arrive pas à la lier avec ma liste d'avion, une ArrayList renseignée.

    J'ai tenté ceci :
    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
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    /*
     * i_trafficAerien.java
     *
     * Created on 21 mars 2009, 19:05:05
     */
     
    package trafficaerien;
     
    import java.util.ArrayList;
     
    /**
     *
     * @author Deallyra
     */
    public class i_trafficAerien extends javax.swing.JDialog {
     
        /** Creates new form i_trafficAerien */
        public i_trafficAerien(java.awt.Frame parent, boolean modal) {
            super(parent, modal);
            initComponents();
        }
     
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
     
            jCB_ListeAvion = new javax.swing.JComboBox();
            jLBL_Avion = new javax.swing.JLabel();
            jLBL_Resultat = new javax.swing.JLabel();
            jLBL_Titre = new javax.swing.JLabel();
            jLBL_Resultat_avant = new javax.swing.JLabel();
            jCB_ListeVol = new javax.swing.JComboBox();
            jLBL_Vol = new javax.swing.JLabel();
            jLBL_resultat_apres = new javax.swing.JLabel();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            setTitle("Traffic Aerien");
     
            jCB_ListeAvion.setModel(null);
            for(int i=0; i <= desAvions.size(); i++){
                jCB_Avion.addItem(desAvions.get(i).getMarque());
            }
            jCB_ListeAvion.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jCB_ListeAvionActionPerformed(evt);
                }
            });
     
            jLBL_Avion.setText("Choisir un Avion :");
     
            jLBL_Resultat.setText("ne peut pas");
     
            jLBL_Titre.setFont(new java.awt.Font("Monotype Corsiva", 1, 24));
            jLBL_Titre.setForeground(java.awt.Color.blue);
            jLBL_Titre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLBL_Titre.setText("Traffic Aerien");
     
            jLBL_Resultat_avant.setText("Cet avion");
     
            jCB_ListeVol.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
     
            jLBL_Vol.setText("Choisir un Vol :");
     
            jLBL_resultat_apres.setText("faire ce vol.");
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap(125, Short.MAX_VALUE)
                    .addComponent(jLBL_Resultat_avant)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLBL_Resultat)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLBL_resultat_apres)
                    .addGap(103, 103, 103))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLBL_Vol, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLBL_Avion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGap(14, 14, 14)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jCB_ListeVol, javax.swing.GroupLayout.Alignment.LEADING, 0, 243, Short.MAX_VALUE)
                        .addComponent(jCB_ListeAvion, javax.swing.GroupLayout.Alignment.LEADING, 0, 243, Short.MAX_VALUE))
                    .addGap(49, 49, 49))
                .addComponent(jLBL_Titre, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jLBL_Titre, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(36, 36, 36)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jCB_ListeAvion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLBL_Avion))
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jCB_ListeVol, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLBL_Vol))
                    .addGap(31, 31, 31)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLBL_Resultat_avant)
                        .addComponent(jLBL_Resultat, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLBL_resultat_apres))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
     
            pack();
        }// </editor-fold>
     
        private void jCB_ListeAvionActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
    }
     
        /**
        * @param args the command line arguments
        */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    i_trafficAerien dialog = new i_trafficAerien(new javax.swing.JFrame(), true);
                    dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                        @Override
                        public void windowClosing(java.awt.event.WindowEvent e) {
                            System.exit(0);
                        }
                        public void windowOpening(java.awt.event.WindowEvent e) {
                            Avion a1 = new Avion("Airbus A340-300", 295, 129300, 55600, 100, 13000, 140640,140640);
                            Avion a2 = new Avion("Boeing 747-400", 524, 178756, 218134, 200, 10668, 216840,216840);
                            Avion a3 = new Avion("Cessna 150", 2, 480, 246, 50, 3855, 140,140);
                            desAvions.add(a1);
                            desAvions.add(a2);
                            desAvions.add(a3);
                        }
                    });
                    dialog.setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify
        private javax.swing.JComboBox jCB_ListeAvion;
        private javax.swing.JComboBox jCB_ListeVol;
        private javax.swing.JLabel jLBL_Avion;
        private javax.swing.JLabel jLBL_Resultat;
        private javax.swing.JLabel jLBL_Resultat_avant;
        private javax.swing.JLabel jLBL_Titre;
        private javax.swing.JLabel jLBL_Vol;
        private javax.swing.JLabel jLBL_resultat_apres;
        // End of variables declaration
        static protected ArrayList<Avion> desAvions = new ArrayList<Avion>();
    }
    Merci à vous,
    *Si la réponse vous convient, n'oubliez pas le tag
    *Exprimez vous dans un français correct; on prend le temps de vous lire, prenez le temps de bien écrire.
    *Et comment on interprète votre code? N'oubliez pas la balise!

    *Pour une mise en page simple avec des divs.
    *Pour faire des formulaires xHTML CSS.

  2. #2
    Membre Expert
    Avatar de X-plode
    Ingénieur développement logiciels
    Inscrit en
    Décembre 2005
    Messages
    682
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Décembre 2005
    Messages : 682
    Par défaut
    Bonsoir,

    Je pense que ce lien pourrait t'interesser et j'espere t'apporter quelques reponses

  3. #3
    Membre expérimenté Avatar de jiddou
    Inscrit en
    Août 2007
    Messages
    247
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 247
    Par défaut
    Je te propose de faire ainsi c'est plus propre, on laisse la vue et on manipule le model.

    Déclaration comme attribut :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    Liste Avion :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    jCB_ListeAvion = new javax.swing.JComboBox(model);
    et pour la manipulation on touche plus au combo mais plutôt à son modèle:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
            for(int i=0; i <= desAvions.size(); i++){
                model.addElement(desAvions.get(i).getMarque());
            }
    N'oublies pas de retirer cette instruction c'est elle qui gâche tout à mon avis:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    jCB_ListeAvion.setModel(null);

  4. #4
    Inactif   Avatar de Deallyra
    Profil pro
    Étudiant
    Inscrit en
    Février 2007
    Messages
    1 997
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2007
    Messages : 1 997
    Par défaut
    Citation Envoyé par X-plode Voir le message
    Bonsoir,

    Je pense que ce lien pourrait t'interesser et j'espere t'apporter quelques reponses
    Merci pour ce lien. En effet, il m'a montré une solution. Il faudrait que j'implémente une nouvelle classe pour le gérer.

    Citation Envoyé par jiddou Voir le message
    Je te propose de faire ainsi c'est plus propre, on laisse la vue et on manipule le model.
    (...)
    J'ai à présent ce code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    jCB_ListeAvion = new javax.swing.JComboBox(model);
    for(int i=0; i <= desAvions.size(); i++){
                model.addElement(desAvions.get(i).getMarque());
            }
                model.addElement(new String("toto"));
    jCB_ListeAvion.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jCB_ListeAvionActionPerformed(evt);
        }
    });
    ce qui me donne, lorsque je demande une preview du design, ceci :


    Ne devrais-je pas voir au minimum un item "toto" dans la liste ?
    *Si la réponse vous convient, n'oubliez pas le tag
    *Exprimez vous dans un français correct; on prend le temps de vous lire, prenez le temps de bien écrire.
    *Et comment on interprète votre code? N'oubliez pas la balise!

    *Pour une mise en page simple avec des divs.
    *Pour faire des formulaires xHTML CSS.

  5. #5
    Membre expérimenté Avatar de jiddou
    Inscrit en
    Août 2007
    Messages
    247
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 247
    Par défaut
    Ok Alors là il y'a problème et j'ai vu ou est ce que c'est.

    Ton code n'est jamais exécuté tout simplement. Et c'est dû au fait que ta méthode windowOpening n'existe pas pour les windowListener.
    Elle n'existe pas et je trouve qu'elle est inutile.Un traitement que tu veux faire au demarrage de ton frame tu peux le mettre dans ton constructeur ou mieux après l'instantiation de ton JCombo.
    Voici le code qui en résulte sauf qu'à la place d'Avion j'utilise du string directement .

    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
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    /*
     * i_trafficAerien.java
     *
     * Created on 21 mars 2009, 19:05:05
     */
     
    package tets;
     
    import java.util.ArrayList;
     
    import javax.swing.DefaultComboBoxModel;
     
    /**
     *
     * @author Deallyra
     */
    public class i_trafficAerien extends javax.swing.JDialog {
     
        /** Creates new form i_trafficAerien */
        public i_trafficAerien(java.awt.Frame parent, boolean modal) {
            super(parent, modal);
            initComponents();
        }
     
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
     
        	jCB_ListeAvion = new javax.swing.JComboBox(model);// j'ai changé cette declaration
            jLBL_Avion = new javax.swing.JLabel();
            jLBL_Resultat = new javax.swing.JLabel();
            jLBL_Titre = new javax.swing.JLabel();
            jLBL_Resultat_avant = new javax.swing.JLabel();
            jCB_ListeVol = new javax.swing.JComboBox();
            jLBL_Vol = new javax.swing.JLabel();
            jLBL_resultat_apres = new javax.swing.JLabel();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            setTitle("Traffic Aerien");
            //Bloc de preparation des avions : ne pas oublier de changer les String par des avions
            String a1 = "Airbus A340-300";
            String a2 = "Boeing 747-400";
            String a3 = "Cessna 150";
            desAvions.add(a1);
            desAvions.add(a2);
            desAvions.add(a3);
            ///////////////////////////////////////////////////////////////////////////////////
            for(int i=0; i < desAvions.size(); i++){
                model.addElement(desAvions.get(i));  // Il faut Ajouter les .getMarque
            }
                jCB_ListeAvion.addActionListener(new java.awt.event.ActionListener() {
                	public void actionPerformed(java.awt.event.ActionEvent evt) {
                		jCB_ListeAvionActionPerformed(evt);
                	}
                });
     
            jLBL_Avion.setText("Choisir un Avion :");
     
            jLBL_Resultat.setText("ne peut pas");
     
            jLBL_Titre.setFont(new java.awt.Font("Monotype Corsiva", 1, 24));
            jLBL_Titre.setForeground(java.awt.Color.blue);
            jLBL_Titre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLBL_Titre.setText("Traffic Aerien");
     
            jLBL_Resultat_avant.setText("Cet avion");
     
            jCB_ListeVol.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
     
            jLBL_Vol.setText("Choisir un Vol :");
     
            jLBL_resultat_apres.setText("faire ce vol.");
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap(125, Short.MAX_VALUE)
                    .addComponent(jLBL_Resultat_avant)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLBL_Resultat)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLBL_resultat_apres)
                    .addGap(103, 103, 103))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLBL_Vol, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLBL_Avion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGap(14, 14, 14)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jCB_ListeVol, javax.swing.GroupLayout.Alignment.LEADING, 0, 243, Short.MAX_VALUE)
                        .addComponent(jCB_ListeAvion, javax.swing.GroupLayout.Alignment.LEADING, 0, 243, Short.MAX_VALUE))
                    .addGap(49, 49, 49))
                .addComponent(jLBL_Titre, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jLBL_Titre, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(36, 36, 36)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jCB_ListeAvion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLBL_Avion))
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jCB_ListeVol, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLBL_Vol))
                    .addGap(31, 31, 31)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLBL_Resultat_avant)
                        .addComponent(jLBL_Resultat, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLBL_resultat_apres))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
     
            pack();
        }// </editor-fold>
     
        private void jCB_ListeAvionActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
    }
     
        /**
        * @param args the command line arguments
        */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    i_trafficAerien dialog = new i_trafficAerien(new javax.swing.JFrame(), true);
                    dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                        @Override
                        public void windowClosing(java.awt.event.WindowEvent e) {
                            System.exit(0);
                        }
                    });
                    dialog.setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify
        private javax.swing.JComboBox jCB_ListeAvion;
        private javax.swing.JComboBox jCB_ListeVol;
        private javax.swing.JLabel jLBL_Avion;
        private javax.swing.JLabel jLBL_Resultat;
        private javax.swing.JLabel jLBL_Resultat_avant;
        private javax.swing.JLabel jLBL_Titre;
        private javax.swing.JLabel jLBL_Vol;
        private javax.swing.JLabel jLBL_resultat_apres;
        // End of variables declaration
        static protected ArrayList<String> desAvions = new ArrayList<String>();
        DefaultComboBoxModel model = new DefaultComboBoxModel();
    }
    Attention : ne jamais faire ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    for(int i=0; i <= desAvions.size(); i++)
    C'est plutôt

  6. #6
    Inactif   Avatar de Deallyra
    Profil pro
    Étudiant
    Inscrit en
    Février 2007
    Messages
    1 997
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2007
    Messages : 1 997
    Par défaut
    Ca fonctionne nickel :3

    Merci beaucoup ^^


    J'ai bel et bien mes avions qui apparaissent avec toto

    Merci jiddou pour la solution finale.

    Attention : ne jamais faire ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    for(int i=0; i <= desAvions.size(); i++)
    Hum... C'est vrai que les index commencent à 0... Vive les nullPointerException de mon précédent code :s
    *Si la réponse vous convient, n'oubliez pas le tag
    *Exprimez vous dans un français correct; on prend le temps de vous lire, prenez le temps de bien écrire.
    *Et comment on interprète votre code? N'oubliez pas la balise!

    *Pour une mise en page simple avec des divs.
    *Pour faire des formulaires xHTML CSS.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 29
    Dernier message: 16/04/2015, 19h29
  2. Saisir une image à partir d'une photo ou d'une vidéo
    Par lohengrin56 dans le forum Flash/Flex
    Réponses: 0
    Dernier message: 07/07/2009, 16h17
  3. Réponses: 2
    Dernier message: 05/01/2009, 12h45
  4. Réponses: 5
    Dernier message: 22/05/2008, 14h42
  5. [JCombobox] modif d'une jcombobox par rapport à une autre
    Par The Wretched dans le forum Composants
    Réponses: 2
    Dernier message: 21/03/2005, 10h35

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