Want to set the default value selected in JComboBox filled with enumeration

Below the statement in case the condition does not work, give me some decision on how to set the highlighted element to JComboBox, which is filled with ENUM.

      public enum EbayContryEnum 
        {
        AT    (3),
        AU    (4),
        BE    (5),
        CA    (7),
        CH    (14),
        DE    (11),
        ES    (13),
        FR    (10),
        IE    (2),
        IT    (12),
        NL    (16),
        UK    (15),
        US    (1);
        }

for ex: -

if(country.equals("FR"))
                      {
                      cbImportCountry.setSelectedItem("FR");
                      }

But it does not work.

+4
source share
3 answers

cbImportCountry.setSelectedItem(EbayContryEnum.FR);

+6
source
cbImportCountry.setSelectedItem(EbayContryEnum.FR);
+7
source

, combobox. .

:

EbayContryEnum.valueOf("FR");
0

All Articles