JComponent_MultithreadedTest.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:cn1 作者:
protected boolean requestFocusInWindowForComponent(final JComponent c, int maxWaitTime)
        throws Exception {
    FocusListener listener = addFocusListener(c);
    RunnableResulted thread = new RunnableResulted() {
        @Override
        public void run() {
            result = c.requestFocusInWindow();
        }
    };
    SwingUtilities.invokeAndWait(thread);
    if (!thread.result) {
        return false;
    }
    synchronized (listener) {
        listener.wait(maxWaitTime);
    }
    waitForIdle();
    if (!c.isFocusOwner()) {
        fail();
    }
    return true;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号