This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Adding addPopupMenuListener to JCombo Box through Mouse Event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding addPopupMenuListener to JCombo Box through Mouse Event" Watch "Adding addPopupMenuListener to JCombo Box through Mouse Event" New topic
Author

Adding addPopupMenuListener to JCombo Box through Mouse Event

Tim Jones
Greenhorn

Joined: Apr 06, 2008
Posts: 28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding addPopupMenuListener to JCombo Box through Mouse Event
 
Similar Threads
show and hide a JPopupMenu
JComboBox Height
Gui button with calendar popup
JPopupMenu - bug?
Prevent Display of Drop List in JComboBox