Results 1 to 3 of 3

Thread: List Boxes

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

    Default List Boxes


    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?



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


    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 08:03 PM. Reason: add newlines for readability

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Rep Power

Similar Threads

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