我试了一下,当选择第二个"b"时,根本不传递响应ItemEvent消息。用ActionListener监听到了消息,但getSelectedIndex()仍返回1。
Jdk文档是这样说的:
Returns the first item in the list that matches the given item. The result is not always defined if the JComboBox allows selected items that are not in the list. Returns -1 if there is no selected item or if the user specified an item which is not in the list. 从文档中看,确实只返回第一个适配的项。
期待高手!