2021年5月2日星期日

How to change JComboBox items to Integers

How to change JComboBox items to Integers

I Tried to to convert the String that i have get it from the JComboBox to Int like this but there is an Exception

int hrCBvalue = (Integer) hrCB.getSelectedItem();  System.out.println(hrCBvalue);  

This is how i make the JComboBox and it is not editable, How can i edit it?

hrCB.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));  
https://stackoverflow.com/questions/67363351/how-to-change-jcombobox-items-to-integers May 03, 2021 at 12:06PM

没有评论:

发表评论