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 :

Récupération d'item dans une ComboBox


Sujet :

AWT/Swing Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2012
    Messages : 24
    Par défaut Récupération d'item dans une ComboBox
    bonjour a tous
    je vous fournis mon code des deux classes afin de pouvoir m'aider
    je veux récupérer l'item selectionné de mon combobox de la class "combo" sur le label recup_item de ma classe "label"
    j'ai pu l'afficher sur la console mais pas sur la classe label
    voici le code
    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
     
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
     
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
     
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
     
    /*
    * combo.java
    *
    * Created on 21 mai 2012, 22:58:20
    */
     
    /**
    *
    * @author Microbox
    */
    /*--------------------------------------------------------------------------------------------------------------*/
    public class combo extends JFrame implements ActionListener {
    /**
    *
    */
     
    JLabel recup_item;
    /** Creates new form combo */
    public combo() {
    initComponents();
     
    this.setLocationRelativeTo(null);
     
    }
     
    /** 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() {
     
    jPanel1 = new javax.swing.JPanel();
    jComboBox1 = new javax.swing.JComboBox();
    btn_ok = new javax.swing.JButton();
    btn_ok.setText("ok");
    /*--------------------------------------------------------------------------------------------------------------*/
    btn_ok.addActionListener(new label(this));
    /*--------------------------------------------------------------------------------------------------------------*/
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
    jPanel1.setBackground(new java.awt.Color(255, 255, 255));
     
    jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "rouge", "vert", "bleu" }));
    jComboBox1.addActionListener(new java.awt.event.ActionListener() {
    /*--------------------------------------------------------------------------------------------------------------*/
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jComboBox1ActionPerformed(evt);
    }
    });
    /*--------------------------------------------------------------------------------------------------------------*/
    btn_ok.setText("ok");
     
    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(89, 89, 89)
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(btn_ok)
    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(63, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(71, 71, 71)
    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 107, Short.MAX_VALUE)
    .addComponent(btn_ok)
    .addGap(51, 51, 51))
    );
     
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    );
     
    pack();
    }// </editor-fold>
     
    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
    //public void itemStateChanged(ItemEvent ie) {
    recup_item.setText(jComboBox1.getSelectedItem().toString());
    //}
     
    // TODO add your handling code here:
    }
    /*--------------------------------------------------------------------------------------------------------------*/
     
    private void btn_okActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
     
    //new label().setVisible(true);
     
     
    }
    /*--------------------------------------------------------------------------------------------------------------*/
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new combo().setVisible(true);
    }
    });
    }
     
    // Variables declaration - do not modify
    public javax.swing.JButton btn_ok;
    public javax.swing.JComboBox jComboBox1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration
     
    /*--------------------------------------------------------------------------------------------------------------*/
    public JComboBox getjComboBox1(){
    //JLabel recup_item;
     
    return jComboBox1;
     
     
    }
    /*--------------------------------------------------------------------------------------------------------------*/
    @Override
    public void actionPerformed(ActionEvent arg0) {
     
    // TODO Auto-generated method stub
     
    }
     
    }
    ---------------------------LE CODE DE LA CLASS LABEL-----------------------
    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
     
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
     
    import javax.swing.JComboBox;
    import javax.swing.JLabel;
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
     
    /*
    * label.java
    *
    * Created on 21 mai 2012, 23:02:10
    */
     
    /**
    *
    * @author Microbox
    */
    /*--------------------------------------------------------------------------------------------------------------*/
    public class label extends javax.swing.JFrame implements ActionListener {
     
    private combo combo1;
     
    public label(combo combo1) {
    this.combo1=combo1;
    }
    /** Creates new form label */
    public label() {
    initComponents();
    this.setLocationRelativeTo(null);
    //pour ne pas fermer la fenetre précedente aprés close de label//
    setDefaultCloseOperation(this.DISPOSE_ON_CLOSE);
     
     
    }
     
    /** 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() {
    //public void actionPerformed1(ActionEvent arg0) {
    jPanel1 = new javax.swing.JPanel();
    couleur = new javax.swing.JLabel();
    recup_item = new javax.swing.JLabel();
     
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
    jPanel1.setBackground(new java.awt.Color(255, 255, 255));
     
    couleur.setText("couleur choisi");
     
    recup_item.setForeground(new java.awt.Color(255, 51, 0));
    recup_item.setOpaque(true);
     
    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(28, 28, 28)
    .addComponent(couleur, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(30, 30, 30)
    .addComponent(recup_item, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(45, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(64, 64, 64)
    .addComponent(recup_item, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(77, 77, 77)
    .addComponent(couleur)))
    .addContainerGap(151, Short.MAX_VALUE))
    );
     
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
     
    pack();
    }// </editor-fold>
     
    /**
    * @param args the command line arguments
    */
     
     
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new label().setVisible(true);
    }
    });
    }
     
    // Variables declaration - do not modify
    public javax.swing.JLabel couleur;
    private javax.swing.JPanel jPanel1;
    public javax.swing.JLabel recup_item;
    // End of variables declaration
     
    @Override
    /*--------------------------------------------------------------------------------------------------------------*/
     
    public void actionPerformed(ActionEvent arg0) {
     
    // TODO Auto-generated method stub
    //recup_item.setText(combo1.jComboBox1.getSelectedItem().toString());
     
     
     
    String jComboBox1=combo1.getjComboBox1().getSelectedItem().toString();
     
    // recup_item.setText("jComboBox1");
     
    System.out.println(jComboBox1);
    new label().setVisible(true);
     
     
     
    }
    /*--------------------------------------------------------------------------------------------------------------*/
    }
    j'éspére que vous allez m'aidé
    merci d'avance

  2. #2
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2012
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 4
    Par défaut
    Pourquoi générer le code d'une si petite interface ? Fais-le toi même, tu auras quelque chose de bien moins moche compliqué, et tu pourras gérer facilement tes listener

    Je comprends pas trop ce que tu veux faire là, à chaque fois que l'utilisateur clique sur le bouton, tu ouvres une nouvelle fenêtre... Pourquoi ne pas passer en paramètre du constructeur la couleur choisie ?

  3. #3
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2012
    Messages : 24
    Par défaut
    oui merci mais mon interface est un peut charger donc je voulais faire tout d'abord un essai sur une plus simple.
    je veux que l'item choisis ce trouvera sur le jlabel de la fenetre qui s'ouvre
    est t'il possible de m'aidé sur ça ?

  4. #4
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2012
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 4

  5. #5
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2012
    Messages : 24
    Par défaut
    j'ai passé par là mais a aucun moment j'ai pas trouver comment résoudre mon probléme!
    si t'a remarqué il laffiche l'item selectionné dans la console
    si tu peux me dire comment faire pour qu'il le récupére sur recup_item de la frame label
    ça fais plus d'une semaine que je suis là dessus
    merci

  6. #6
    Modérateur
    Avatar de XxArchangexX
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mars 2012
    Messages
    1 159
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 159
    Par défaut
    Bonsoir,

    afiouu c'est bon j'ai trouvé, ce code est une torture ^_^ et un vrai plat de spaghetti.

    Alors

    Dans ta classe combo tu fais un appel sur le bouton ok qui va dans l'action listener de la classe label

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    public void actionPerformed(ActionEvent arg0) {
     
    // TODO Auto-generated method stub
    //recup_item.setText(combo1.jComboBox1.getSelectedItem().toString());
     
    String jComboBox1=combo1.getjComboBox1().getSelectedItem().toString();
     
    // recup_item.setText("jComboBox1");
     
    System.out.println(jComboBox1);
    new label().setVisible(true);
    }
    ici tu fais ta nouvelle fenêtre mais label ne connait rien de combo tu initialises un label sans argument donc tu n'as pas moyen d'afficher la couleur.

    avec ceci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    public void actionPerformed(ActionEvent arg0) {
     
    // TODO Auto-generated method stub
    //recup_item.setText(combo1.jComboBox1.getSelectedItem().toString());
     
    String jComboBox1=combo1.getjComboBox1().getSelectedItem().toString();
     
    // recup_item.setText("jComboBox1");
     
    System.out.println(jComboBox1);
    new label(jComboBox1).setVisible(true);
    }
    Maintenant label connait la couleur à afficher

    Etape 1 : j'ai copié collé la classe, le changement c'est le constructeur qui avant n'avait pas d'argument j'ai mis un string en paramètre que je met dans une variable couleur.

    Etape 2 : j'ai mis le JLabel à jour avec recup_item.setText(_couleur);

    La classe modifiée :

    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
     
    package test;
     
     
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
     
    import javax.swing.JComboBox;
    import javax.swing.JLabel;
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
     
    /*
    * label.java
    *
    * Created on 21 mai 2012, 23:02:10
    */
     
    /**
    *
    * @author Microbox
    */
    /*--------------------------------------------------------------------------------------------------------------*/
    public class label extends javax.swing.JFrame implements ActionListener {
     
    private Test combo1;
    public String _couleur;
    public label(Test combo1) {
    this.combo1=combo1;
     
    }
    /** Creates new form label */
    public label(String couleur) {
    	_couleur = couleur;
    initComponents();
    this.setLocationRelativeTo(null);
    //pour ne pas fermer la fenetre précedente aprés close de label//
    setDefaultCloseOperation(this.DISPOSE_ON_CLOSE);
     
     
    }
     
    /** 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() {
    //public void actionPerformed1(ActionEvent arg0) {
    jPanel1 = new javax.swing.JPanel();
    couleur = new javax.swing.JLabel();
    recup_item = new javax.swing.JLabel();
    recup_item.setText(_couleur);
     
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
    jPanel1.setBackground(new java.awt.Color(255, 255, 255));
     
    couleur.setText("couleur choisi");
     
    recup_item.setForeground(new java.awt.Color(255, 51, 0));
    recup_item.setOpaque(true);
     
    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(28, 28, 28)
    .addComponent(couleur, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(30, 30, 30)
    .addComponent(recup_item, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(45, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(64, 64, 64)
    .addComponent(recup_item, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(77, 77, 77)
    .addComponent(couleur)))
    .addContainerGap(151, Short.MAX_VALUE))
    );
     
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
     
    pack();
    }// </editor-fold>
     
    /**
    * @param args the command line arguments
    */
     
     
    // Variables declaration - do not modify
    public javax.swing.JLabel couleur;
    private javax.swing.JPanel jPanel1;
    public javax.swing.JLabel recup_item;
    // End of variables declaration
     
    @Override
    /*--------------------------------------------------------------------------------------------------------------*/
     
    public void actionPerformed(ActionEvent arg0) {
     
    String jComboBox1=combo1.getjComboBox1().getSelectedItem().toString();
     
     
    new label(jComboBox1).setVisible(true);
     
     
     
    }
    /*--------------------------------------------------------------------------------------------------------------*/
    }
    Remarque : je répond à ton problème mais même si tu le sais peut être, pour le principe je tiens à te dire que si tu évolues ton code tu vas souffrir :s. Je te conseil de le revoir un peu.
    L'Etat est bien administré quand l'escalier de l'école est usé et que l'herbe croît sur celui du tribunal.

    Modérateur BI

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

Discussions similaires

  1. [AC-2010] Impossibilité de selection d'item dans une combobox.
    Par MmD_host dans le forum VBA Access
    Réponses: 5
    Dernier message: 21/08/2012, 14h31
  2. Masquer un item dans une comboBox
    Par gazeux_snake dans le forum AWT/Swing
    Réponses: 0
    Dernier message: 08/01/2010, 12h12
  3. Réponses: 6
    Dernier message: 26/08/2009, 12h14
  4. selection d'un item dans une ComboBox remplie via WCF
    Par Lazslo dans le forum Silverlight
    Réponses: 0
    Dernier message: 18/11/2008, 20h01
  5. Création d'items dans une comboBox
    Par Nicolas2074 dans le forum Sharpdevelop
    Réponses: 3
    Dernier message: 26/04/2007, 09h49

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