multiple JComboBox listeners

75 Views Asked by At

I am new to JComboBox

I have 4 JComboBoxes: specialite, etudiant, annee, and semestre.

I need to get the selected item from the 4 of them each time I change the selected item and add the result to the ScrollPane (groupe des matieres ouvertes)

Project Screenshot

1

There are 1 best solutions below

1
Udaya Shankara Gandhi Thalabat On

Please look into the below JComboBox basic example given by Java. Use getSelectedItem() of JComboBox in actionPerformed() method of each combo box whenever an item got selected in it.

public void actionPerformed(ActionEvent e) {
        JComboBox cb = (JComboBox)e.getSource();
        String petName = (String)cb.getSelectedItem();
        updateScrollpane(petName); // Update your scrollpane
}

Do the same thing for all of your 4 dropdowns and update the scrollpane