Java awt.list ActionListener single click -


i have list of cities. when click on city shows current time, date etc.. city

however updates when double click on city how go changing single click

thanks

 @override public void itemstatechanged(itemevent e) {     set<string> countries = regionmap.get(listregion.getselecteditem());     listsubregion.removeall();     for(string country : countries)     {         listsubregion.add(country);     }      selectedregion = listregion.getselecteditem();      listsubregion.validate();     listsubregion.repaint();      repaint(); } 

try this:

list.addmouselistener(new mouseadapter() {     public void mouseclicked(mouseevent e) {         if (mouseevent.getclickcount() == 1) {             // single click             int index = thelist.locationtoindex(mouseevent.getpoint());             if (index >= 0) {                 object o = thelist.getmodel().getelementat(index);                 ... ...                         }         }     } }); 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -