Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JList ListSelectionListener executes twice! I only need it to run one time.

843806Jun 20 2008 — edited Feb 4 2010
Hi everyone!

I am having trouble with my list selection listener. Every time I select an item in the JList the code for my listener runs twice.
For example, the code snipet like this:
ListSelectionListener listSelectionListener1 = new ListSelectionListener(){
		public void valueChanged(ListSelectionEvent listSelectionEvent){
			System.out.println("Hello");
		}
	};
This will print "Hello" twice and I can't figure out why. It is murdering my program. I have another way of getting around it but it is not very efficient and it makes the program much slower due to a special engine I have initiated during runtime. If there is a way to only get the code to execute once I would appreciate any help.

Thanks!

~Chris
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 4 2010
Added on Jun 20 2008
5 comments
673 views