[JCombobox] Afficher info par rapport à un choix
Bonjour,
Je ne suis pas très expérimenté en développement et cela fait plusieurs jours que je cherche à réaliser ceci:
A partir d'un choix que j'effectue dans une JCombobox qui contient des clients, je désirerais afficher les informations relatives à ceux-ci.
Cependant, je ne parviens pas à déclencher une action en fonction d'un changement dans cette box.
Voici mon code simplifié,
Code:
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
|
public class Ecran extends javax.swing.JFrame {
JComboBox jComboBoxClient = new JComboBox();
JTextField champNom = new JTextField();
JTextField champTel = new JTextField();
JTextField champPrenom = new JTextField();
public Ecran(Connection connection, Database DataB) {
initComponents();
}
private void initComponents() {
for (int i=0;i<clients.size();i++){
jComboBoxClient.addItem(clients.get(i));
}
champTel.setEditable(true);
champPrenom.setEditable(true);
champNom.setEditable(true);
pack();
}
} |
Que puis-je faire pour déclencher un évènement? Comme pour un bouton?
Comment puis-je récupérer la valeur?
MErci d'avance!