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

  1. #1
    Membre à l'essai
    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
    Points : 13
    Points
    13
    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
    Points : 5
    Points
    5
    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 à l'essai
    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
    Points : 13
    Points
    13
    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
    Points : 5
    Points
    5

  5. #5
    Membre à l'essai
    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
    Points : 13
    Points
    13
    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 : 36
    Localisation : France

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

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 159
    Points : 2 323
    Points
    2 323
    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

  7. #7
    Membre à l'essai
    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
    Points : 13
    Points
    13
    Par défaut
    merci de m'avoir répondu mais ça marche pas!
    il me donne erreur au niveau de Test
    """est ce que tu utilise import org.junit.Test;?""""
    et String jComboBox1=combo1.getjComboBox1().getSelectedItem().toString();
    et aussi au niveau de la classe combo il reconné pas le constyructeur de la classe label!

  8. #8
    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 : 36
    Localisation : France

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

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 159
    Points : 2 323
    Points
    2 323
    Par défaut
    aaa non ^_^ chez moi j'ai changé le nom de la classe combo j'ai utilisé une classe vide que j'avais qui s'appel Test . Remplace les Test par combo sa devrais fonctionner.
    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

  9. #9
    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 : 36
    Localisation : France

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

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 159
    Points : 2 323
    Points
    2 323
    Par défaut
    classe combo
    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
     
     package test;
     
    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 {
    /**
    *
    */
     
    public label test;
    /** 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");
    /*--------------------------------------------------------------------------------------------------------------*/
    test = new label(this);
    btn_ok.addActionListener(test);
    /*--------------------------------------------------------------------------------------------------------------*/
    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) {
     
    }
    /*--------------------------------------------------------------------------------------------------------------*/
     
    private void btn_okActionPerformed(java.awt.event.ActionEvent evt) {
     
    }
    /*--------------------------------------------------------------------------------------------------------------*/
    /**
    * @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
     
    }
     
    }
    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
    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 combo combo1;
    public String _couleur;
    public label(combo 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);
     
     
     
    }
    /*--------------------------------------------------------------------------------------------------------------*/
    }
    voila tu peux faire un copier coller sa fonctionne normalement. J'ai retiré le main dans label qui ne sert pas à grand chose car la fenêtre principale c'est combo.
    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

  10. #10
    Membre à l'essai
    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
    Points : 13
    Points
    13
    Par défaut
    merci bcp bcp
    j'ai pu affiché le résultat
    donc pour mon code je vais revoir parceque mon interface contient plein de combobox
    les items du la combobox sont récupérer a partir de la base de donnée
    est ce que y aura pas de changement a faire pour que je puisse faire la méme chose avec cet exemple??
    merci encore

  11. #11
    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 : 36
    Localisation : France

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

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 159
    Points : 2 323
    Points
    2 323
    Par défaut
    Tu peux utiliser cet exemple, il faut que tu fasses une fonction qui retourne un vector. Cette fonction se connecte à ta base retourner le résultat dans un vector , ainsi quand tu initialises ta comboBox tu appels la fonction en retournant le vector ta comboBox contiendra les valeurs de ta base.
    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

  12. #12
    Membre à l'essai
    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
    Points : 13
    Points
    13
    Par défaut
    ok merci

  13. #13
    Membre à l'essai
    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
    Points : 13
    Points
    13
    Par défaut
    bonsoir;
    je reviens encore sur ce sujet
    au fait dans mon application ya plusieurs documents dont lesquels je dois récupérer les items selectionnée de mes combobox et ma jlist(sachant que les combobox et la jlist sont remplis depuis la BDD).
    est ce que je peux passer a partir du bouton envoyé du panel principale(ou je fais mes choix) a une autre sur laquel je fais le choix du document à affiché?
    je comprend pas trop comment est ce que je dois procéder!!
    merci de m'aidé

  14. #14
    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 : 36
    Localisation : France

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

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

    Si je comprend bien, ce que je te propose comme solution c'est de tout faire dans le même panel, tu fais une étape 1 choix du document et étape 2 choix des critères, avec en bas de cette fenêtre un bouton lancer le traitement. Ainsi l'utilisateur comprend tout de suite qu'il va effectuer un traitement sur le document choisi avec des critères possible.
    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

  15. #15
    Membre à l'essai
    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
    Points : 13
    Points
    13
    Par défaut
    bonsoir;merci de me répondre.
    j'éxplique bien ce que j'ai:
    un panel qui contient tout ce qui est récupérer de la BDD postgresql;
    ce panel est inclus dans une jframe qui elle méme contiens un tabbedpane.
    a partir de mon panel je fais les choix sur combobox ,puis je clique sur le bouton envoyé qui va me dirriger à un autre panel(document)sur la méme frame et qui contiens 6 bouton(parcq j'ai 6 document a établir) et c'est là que l'utilisateur va choisir quel document a affiché (sachant que ce document dois contenir tt ce que l'utilsateur a selectionner) " comme dans l'exemple".
    j'éspére que j'ai pu faire passer mon aidé et j'attend tes proposition toujour et surtt je veux savoir est ce que ça est faisable.
    merci encore pour votre aide XxArchangexX

  16. #16
    Membre à l'essai
    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
    Points : 13
    Points
    13
    Par défaut
    et si ça va compliquer les chose je travaillerai sur l'aidé que tu ma proposer elle me semble bcp plus pratique
    salutation

  17. #17
    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 : 36
    Localisation : France

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

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 159
    Points : 2 323
    Points
    2 323
    Par défaut
    Bonjour,

    L'idée que tu souhaites faire est tout à fait faisable, je ne dis pas que c'est le plus dur mais sa necessite un peu de connaissance sur les fonctions des JPanel et JFrame, je pense surtout au repaint(), UpdateUI() pour le refresh de ta vue.

    L'idée une fois le choix de la comboBox effectué, l'utilisateur clique sur le bouton envoyé donc un ActionListener. Dans ce listener effectuer le ou les traitement(s) sur tes documents puis agradir ta fenêtre setSize() il me semble et pour finir un AddComponent() avec le repaint pour mettre à jour la vue.

    Ainsi tu auras le choix des critères et au clique sur envoyé la fenêtre prendra la taille du nouveau JPanel avec les 6 boutons.

    En esperant que j'ai bien interpreté ton choix de l'IHM.
    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

  18. #18
    Membre à l'essai
    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
    Points : 13
    Points
    13
    Par défaut
    bonjour et merci pour ta réponse
    mais ya une chose que vraiment j'arrive pas bien à comprendre!
    quand je fais le actionlistener sur le bouton envoyé il va m'affiché le panel ou ya les 6 bouton(sachant qu'on est sur la méme frame) et au clique sur un chois je lui affcihe la frame( le document) désirer.(une frame indépendante)
    ce que je vois pas comment faire connaitre les choix fais sur les combobox au bouton puis au document (est ce que le traitement sera fais sur le bouton envoyé ou bien sur un des bouton du choix de doc!!!!!).
    Remarque:
    j'ai fais mes interface avec netbeans; (pour les frame document j'ai utiliser un absolutelayout)
    et j'utilise le code sous eclipse.

  19. #19
    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 : 36
    Localisation : France

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

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 159
    Points : 2 323
    Points
    2 323
    Par défaut
    Pour moi le traitement sera effectué dans l'action Listener du bouton envoyé, ainsi quand tu cliques sur le bouton d'un document se sera juste de l'affichage.

    Pour ce qui est de la mise en oeuvre, c'est algorithmique à vérifier pour la syntaxe :

    ta fenetre
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Controleur boutonEnvoye = new Controleur(this)
    JButton envoye = new JButton("envoye");
    envoye.addActionListener(boutonEnvoye);
    classe controleur
    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
     
    Class Controleur implement ActionListener{
     
    fenetre _fen;
    public Controleur(fenetre fen){
     
    _fen = fen;
     
    }
     
    Action(evt){
    // traitement des critères gràce à fen tu as accès au choix des comboBox
     
    // Mise en place du JPanel avec les boutons
     
    // _fen . add le JPanel
     
    //mise à jours de la fenetre _fen.UpdateUI();
    }
    }
    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

  20. #20
    Membre à l'essai
    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
    Points : 13
    Points
    13
    Par défaut
    ok merci
    je tombe déja sur le probléme de changement de panel sur la frame
    je vais le faire puis je passe au traitements
    merci pour tous

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

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