开发者

How to get Label into thread?

First off let me show you my code:

Thread: http://pastebin.com/ie4WD5W8

Then to call the thread i used the following...

    randomKeyGen key1 = new randomKeyGen(ranLKey);
    key1.start();

ranLKey is my label and I can't figure out why it won't work. As long as I do not try to put a label in the thread it works, but that defeats the entire purpose. So the above code does NOT work, but the code from pastebin seems to be fine. Hopefully you can help me out with what I am doing wrong.

I am using netbeans if that helps at all. Also talked about this before in multiple places. So if you saw me before, then just letting you know I am still looking for he开发者_开发百科lp.

Thanks in advanced!


I believe the issue might be in the mainFrame's setKey(String) and/or getKey() calls. Aren't they play with something in GUI? If so they should go through event dispatch thread, similar to the label setting (try invokeAndWait(Runnable)). What's more it's advised to check first for the event dispatch thread before creating a new runnable (isEventDispatchThread()).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜