The Source for Java Technology Collaboration

Home » java.net Forums » Java Desktop Technologies » Swing & AWT

Thread: JList SelectionEvent Problem (On mouse press it works twice)

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is not answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 1 - Last Post: Oct 22, 2008 3:49 AM by: walterln Threads: [ Previous | Next ]
sandeep_mandori

Posts: 1
JList SelectionEvent Problem (On mouse press it works twice)
Posted: Oct 21, 2008 10:11 PM
 
  Click to reply to this thread Reply

Hi

I have a strange problem in my swing application.
Problem arises when i call a selection listener on a jlist.
what i am doing is :- i am calling a database method from my selection event block and in db side i am firing a query in the database after that i display all the data on my JTable Object.
But there is ambiguity in the behavior of the JList's Selection event.
When i select an element in JList by the Keyboards UP and Down arrow button then code working fine that means query executed once.....But when i select an element from mouse
then my query executed twice....how i can handle that situation in the JList's selectionEvent.

walterln

Posts: 278
Re: JList SelectionEvent Problem (On mouse press it works twice)
Posted: Oct 22, 2008 3:49 AM   in response to: sandeep_mandori
 
  Click to reply to this thread Reply

In case of the mouse click two events are fired:
-deselecting the old row
-selecting the new row

The first event has ListSelectionEvent#getValueIsAdjusting() set to true, so don't respond in that case.




 XML java.net RSS