java - How can I hold the menu open in the JComboBox? -


i have create custom jcombobox, if try open combobox, can see check button near description. ok. if want select n items must, open select list, check 1 items, re-open select list, select items, open select list etc... want open select list 1 times select list want close select list. possibile it?

this checkcombostore

public class checkcombostore {     string id;     boolean state;     string nomearticolo;      public checkcombostore(string id, string nomearticolo,boolean state)     {         this.id = id;         this.nomearticolo=nomearticolo;         this.state = state;     }      public string getid() {         return id;     }      public void setid(string id) {         this.id = id;     }      public boolean getstate() {         return state;     }      public void setstate(boolean state) {         this.state = state;     }      public string getnomearticolo() {         return nomearticolo;     }      public void setnomearticolo(string nomearticolo) {         this.nomearticolo = nomearticolo;     }         } 

this code create combobox check button

   list<articoli> listaarticoli = modelmanager.getarticolimanager().estraiarticoli(false,false,false,false,false);         checkcombostore[] stores = new checkcombostore[listaarticoli.size()];         int i=0;         for(iterator<articoli>it=listaarticoli.iterator(); it.hasnext();){             articoli art = it.next();             stores[i] = new checkcombostore(art.getcodarticolostring(),art.getnomearticolo(),false);             i++;         }     comboboxarticoli = new comboformat(stores);     comboboxarticoli.setrenderer(new checkcomborenderer()); 

may can try adding listener shown below , when item selected can use invokelater , keep popup open. may not exact solution give idea. let me know if works you?

combo.additemlistener(new itemlistener() {        @override       public void itemstatechanged(itemevent e) {         if (e.getstatechange() == itemevent.selected) {           if (e.getitem() == combo.getitemat(0)) //some condition {              swingutilities.invokelater(new runnable() {                @override               public void run() {                 combo.setselecteditem(lastselecteditem);                 combo.showpopup();               }             });           } else {             lastselecteditem = combo.getselecteditem();           }         }       }     }); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -