2016-05-30 3 views
0

をクリックした後、私はselectedIndexので記入し、のSelectedItemに必要な項目を選択ではなく、コンボボックスを持って選択した項目にジャンプ。SetSelectedItem doesntのボックス

のselectedIndexの場合には、コンボボックスで必要な値を設定し、選択を強調します。 selectedItemの場合は必要なものを選択しますが、ボックスを押すと、非常に最初からリストが表示されます。 setSelectedIndexを使用せずに、選択した項目を設定する方法

答えて

0

ここにコードを投稿した方が良いでしょう。まだ.. setSelectedItemについてのJavadocからテキストの下にお読みください:

Sets the selected item in the combo box display area to the object in the argument. If anObject is in the list, the display area shows anObject selected. 
    If anObject is not in the list and the combo box is uneditable, it will not change the current selection. For editable combo boxes, the selection will change to anObject. 

    If this constitutes a change in the selected item, ItemListeners added to the combo box will be notified with one or two ItemEvents. If there is a current selected item, an ItemEvent will be fired and the state change will be ItemEvent.DESELECTED.If anObject is in the list and is not currently selected then an ItemEvent will be fired and the state change will be ItemEvent.SELECTED.