• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding addPopupMenuListener to JCombo Box through Mouse Event

 
Tim Jones
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UPDATE: Perhaps there is more elegant/better way to do this?

When comboBox (line 34) is clicked the MouseListener (line 38) calls method "userNames()" (line 51), which sets up a connection to the database and returns an ArrayList. PopupMenuListener "srcListener" (line 8) calls the method "userNames()" and adds it to the comboBox (line 34). Problem: When Mouse Listener activates, combo box population occurs multiple time (should be only once). Another problem is that everytime mouse listener is triggered it appends the ArrayList to the combo box, should delete the existing list before adding the new combo box.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic