Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: is the importData(...) method of a transferHandler run on the EDT?

  1. #1
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    621
    Thanks
    0
    Thanked 112 Times in 97 Posts

    Default is the importData(...) method of a transferHandler run on the EDT?

    Hi,
    just a quick question. When I implement a custom TransferHandler for a JTree / JList, can I expect that the importData method is called on the EDT and that I can simply Insert / Remove to / from the underlying model without having to push events on the EDT?
    Or should I still wrap every action which changes the model up in a EDT.invokeLater(Runnable r) call?

    I am asking because I am getting some visual glitches with and I want to know whether this is because of an error in my own code or because I am not using the EDT there explicitely.

    Thanks in advance.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,295
    My Mood
    Mellow
    Thanks
    193
    Thanked 669 Times in 656 Posts

    Default Re: is the importData(...) method of a transferHandler run on the EDT?

    Or should I still wrap every action which changes the model up in a EDT.invokeLater(Runnable r) call?
    No, that's not necessary. If an event running from a Swing app requires so much CPU time that the interface is impacted, then SwingWorker should be employed.

    What kind of visual glitches are you experiencing?

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    621
    Thanks
    0
    Thanked 112 Times in 97 Posts

    Default Re: is the importData(...) method of a transferHandler run on the EDT?

    With my JTree I get some blank lines and not correctly drawn selection boxes. I observed the same behavior when modifying the model from a different thread then the EDT in the past.
    Furthermore, these glitches seem to come at random. I was monitoring every TreeModelEvent with a separate listener and writing them to an output.
    When I noticed this glitch I restarted the application and repeated all steps from the previous run in the exact order. The same glitch did not appear at the same time, but sometimes earlier and sometimes later.
    This is another reason why I was thinking that this might be because of events being fired out of sync.

Similar Threads

  1. Cannot get TransferHandler to work in Swing
    By pbpersson in forum AWT / Java Swing
    Replies: 2
    Last Post: January 31st, 2011, 09:07 PM
  2. Re: Can't run the method, Please help!!
    By snowman_heman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 31st, 2011, 07:35 PM
  3. Thread to EDT
    By Asido in forum Threads
    Replies: 3
    Last Post: October 15th, 2010, 01:13 PM
  4. updating EDT with thread swingworker/invokeLater ?
    By mdstrauss in forum AWT / Java Swing
    Replies: 0
    Last Post: October 11th, 2009, 04:52 AM
  5. Replies: 0
    Last Post: October 10th, 2009, 01:25 PM