added check for UI Thread

What do you think about this for issue #604? 

I don't know how you feel about using JExpr.direct().  I was trying to do it without it but couldn't figure it out immediately.  I can look into it more if you don't like using direct().