Results 1 to 3 of 3

Thread: List Boxes

  1. #1
    zzpprk is offline Member
    Join Date
    Aug 2009
    Posts
    26
    Rep Power
    0

    Default List Boxes

    Hi

    I have a list box which fires the valueChanged event each time the selected line changes. This has the unwanted side-effect of firing an event for every line traversed if you press and hold-down the up or down arrow key. Is there a way of getting this event fired only once when the highlight comes to rest on a line (i.e. when the user releases the arrow key)? Are they different events I could handle to achieve that?

    Regards

    Patrick

  2. #2
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default

    Your application could keep track of the mouse buttons
    and only respond to valueChanged() when all are up.
    This would be done by adding a mouseListener to the JList.
    Override mousePressed to set a flag that a button is down
    and mouseReleased to clear the flag when all buttons are up.

    When I started thinking about this problem,
    I found I had to go further and keep track of which keys were down.
    The code I wrote used a BitSet to keep track of which keys were down.

    It gets worse. On some platforms when a key is held down repeated up/down events are sent.
    The problem is discussed at length on an old post.
    Last edited by zweibieren; 12-15-2009 at 09:03 PM. Reason: add newlines for readability

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

Similar Threads

  1. Duplicate Input Boxes
    By habester in forum New To Java
    Replies: 3
    Last Post: 11-09-2009, 07:13 PM
  2. Dragging Boxes
    By anilanar in forum New To Java
    Replies: 8
    Last Post: 09-05-2009, 10:23 PM
  3. [SOLVED] Combo Boxes Automation
    By dbashby in forum New To Java
    Replies: 3
    Last Post: 03-27-2009, 01:39 AM
  4. Retrieve values of Text boxes using LIST
    By Kayal in forum Web Frameworks
    Replies: 2
    Last Post: 03-20-2009, 12:00 PM
  5. Help! Need to randomly assign boxes
    By newb101 in forum New To Java
    Replies: 1
    Last Post: 09-16-2008, 11:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •