This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
When I create a JList component on a JFrame window using the GUIDesigner tool and then add a ListSelectionListener to the JList component, and then running the application and selecting one of the items in the list the valueChanged method is executed twice instead of only once. In order to make sure it wasn't my own code I created a very simple frame with the JList as the only component and the problem persisted. I added the listener using anonymous class and an inner class and neither worked. I also imported working code (not generated with the form editor) with a simple JList component and ran it with NetBeans and the valueChanged executed only once as it was supposed to. The form editor code looks fine so perhaps the EventDispatcher Thread is dispatching the same event more than once???
This is a misunderstanding. The event is delivered "twice" if you change selection using mouse. The first event is delivered on mouse-press event and its valueAdjusting property is set to true. This denotes that the selection may not be finished (when you move mouse pointer over another item in the list while holding button pressed then another event of this type is delivered). When you release mouse button then a new event is generated (with valueAdjusting property set to false) denoting that the selection was finalized. If you don't want to react on temporary selections then your event handler should check whether the delivered event has valueAdjusting property set to true and don't react otherwise.