Results 1 to 4 of 4
  1. #1
    SeanC is offline Member
    Join Date
    Aug 2010
    Posts
    24
    Rep Power
    0

    Question How to stop a JList from firing events when contents is updated?

    Hi all, I'm currently trying to solve a problem with a JList. I've got an actionPerformed event applied to the JList (also tried the item updated event but it has the same effect), and whenever this event is fired, (i.e. the user makes a selection), something happens. Now, the problem is that when the list is being populated, it seems to fire the event too - thus creating problems for me.

    Is there a way to stop the JList from firing the actionPerformed or itemStateChanged event when the contents is updated?

    Thanks

    P.S. Question has also been asked here: How to stop a JList from firing events when contents is updated? - Java

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    Add the listener after populating the JList. If that's not an option, remove the listener, populate the JList and then add the listener back.

    db

  3. #3
    SeanC is offline Member
    Join Date
    Aug 2010
    Posts
    24
    Rep Power
    0

    Default

    The former isn't an option as the list is constantly being updated with different values through my PostrgreSQL database. However, i could look into the latter. Is there a way of doing so with the GUI builder of netbeans, as im auto-generating events from there?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    I don't consider my Swing programming skills adequate to master a visual designer so I can't help you there.

    What prevents you from hand coding your GUI and doing things the easy way?

    db

Similar Threads

  1. nodeChanged() not firing/working?
    By PrinceSendai in forum AWT / Swing
    Replies: 2
    Last Post: 03-24-2011, 03:29 AM
  2. setText is not firing...! Why?
    By N00Bie in forum New To Java
    Replies: 14
    Last Post: 02-20-2011, 09:59 PM
  3. Use stop button to stop moving (stop timers) on JPanel
    By mneskovic in forum New To Java
    Replies: 3
    Last Post: 07-23-2010, 12:50 PM
  4. typed events vs untyped events.
    By Drun in forum SWT / JFace
    Replies: 0
    Last Post: 11-23-2009, 12:22 PM
  5. [SOLVED] JList Expanding when not all contents visible
    By Singing Boyo in forum New To Java
    Replies: 8
    Last Post: 06-01-2009, 05:29 AM

Tags for this Thread

Posting Permissions

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