开发者

How to set the JComboBox back to its default item

开发者 https://www.devze.com 2023-04-12 05:40 出处:网络
I have 24 JComboBox consisting of numbers, 2 JButton for \"COMPUTE\" and \"CLEAR ALL\". my COMPUTE BUTTON works just fine. But for the CLEAR ALL button I cant get my desired outcome. I would like to h

I have 24 JComboBox consisting of numbers, 2 JButton for "COMPUTE" and "CLEAR ALL". my COMPUTE BUTTON works just fine. But for the CLEAR ALL button I cant get my desired outcome. I would like to have the clear JButton to act when clicked, by returning all JComboBox to its default number 0. Please h开发者_Python百科elp. What would be the best code for this.


setSelectedItem(Integer.valueOf(0));

Give this in the event-handler of CLEAR ALL button.


jcombobox.setSelectedIndex(0); works fine than jcombobox.setSelectedItem(Integer.valueof(0); in different scenario

0

精彩评论

暂无评论...
验证码 换一张
取 消