swing - Adding list to JCombobox in java -


i have list has added jcombobox.

my code is

serialportcombobox=new jcombobox<string>(); serialportcombobox.setmodel(new defaultcomboboxmodel(list.toarray())); serialportcombobox.setbounds(125, 80, 220, 25); serialporttab.add(serialportcombobox); 

tried didnt work.

im setting list frame , using list in combobox.

code is

configbtn.addactionlistener(new actionlistener()      {          @override         public void actionperformed(actionevent e)         {             // todo auto-generated method stub             try             {              keypadconfig key=new keypadconfig();             key.setid(serialportlist,hashlist);             key.setvisible(true);             }             catch(exception e1)             {                e1.printstacktrace();                 }         }     });      contentpane.add(keypadconfigbtn); 

this used in keypadconfig

public void setid(list<string> serialportlist,         hashmap<string, list<string>> hashlist) {     // todo auto-generated method stub     seriallist=hashlist;     list=serialportlist;   } 

but list null when set combobox in setid list not null.how add list in setid combobox. please help

your first code fragment might taken keypadconfig constructor or method called contructor.

if the case, call setid method after keypadconfig constructed.so when constructing list null.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -