What is the point of JComboBox's getSelectedItem()?

Posted by Chris Cooper on Stack Overflow See other posts from Stack Overflow or by Chris Cooper
Published on 2010-03-29T06:35:45Z Indexed on 2010/03/29 6:43 UTC
Read the original article Hit count: 428

Filed under:
|
|

I just read the JavaDoc for JComboBox (I promise I have a life... I wasn't reading through for fun. =P), and I think the problems I'm having with my program can be attributed to the getSelectedItem() method. The documentation says:

Returns the current selected item.

If the combo box is editable, then this value may not have been added to the combo box with addItem, insertItemAt or the data constructors.

If you can't get values that were added with those methods or with the constructor, of what use is the method? And how can I get the value from an "editable" JComboBox?

Link to JavaDoc: http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComboBox.html#getSelectedItem()

© Stack Overflow or respective owner

Related posts about java

Related posts about jcombobox