• category: swing folder: ClearComboBoxItemSelection title: JComboBoxを選択なしの状態にする tags: [JComboBox] author: aterai pubdate: 2017-03-27T13:52:28+09:00 description: JComboBoxの項目が何も選択されていない状態になるよう設定します。 image: https://drive.google.com/uc?id=1ytLrgrvvfQGy-YNgOPiY67cT8EaLV1yHoA

概要

JComboBoxの項目が何も選択されていない状態になるよう設定します。

サンプルコード

combo.setSelectedIndex(-1);
#spandel
//or: combo.setSelectedItem(null);
#spanend
#spanadd
// or: combo.setSelectedItem(null);
#spanend
View in GitHub: Java, Kotlin

解説

上記のサンプルでは、JComboBox#setSelectedIndex(-1)JComboBox#setSelectedItem(null)JComboBoxの項目がどれも選択されていない状態にするテストを行っています。

参考リンク

コメント