Search code examples
javaswingjcomboboxjlist

Show the first element in a JComboBox


I have a JComboBox with a list of elements. So what the program basically does is user select an element from the combo list and click a button to display the selected element in the text area.

Everything works perfect so far, but the problem is after user click the button I want the combo box to return back to the firs element and display the first element. How can I display the first element of the combo box...????


Solution

  • Try JComboBox#setSelectedIndex(0).