当前位置: 首页>>代码示例>>Java>>正文


Java SunToolkit.isDispatchThreadForAppContext方法代码示例

本文整理汇总了Java中sun.awt.SunToolkit.isDispatchThreadForAppContext方法的典型用法代码示例。如果您正苦于以下问题:Java SunToolkit.isDispatchThreadForAppContext方法的具体用法?Java SunToolkit.isDispatchThreadForAppContext怎么用?Java SunToolkit.isDispatchThreadForAppContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.awt.SunToolkit的用法示例。


在下文中一共展示了SunToolkit.isDispatchThreadForAppContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: revalidate

import sun.awt.SunToolkit; //导入方法依赖的package包/类
/**
 * Supports deferred automatic layout.
 * <p>
 * Calls <code>invalidate</code> and then adds this component's
 * <code>validateRoot</code> to a list of components that need to be
 * validated.  Validation will occur after all currently pending
 * events have been dispatched.  In other words after this method
 * is called,  the first validateRoot (if any) found when walking
 * up the containment hierarchy of this component will be validated.
 * By default, <code>JRootPane</code>, <code>JScrollPane</code>,
 * and <code>JTextField</code> return true
 * from <code>isValidateRoot</code>.
 * <p>
 * This method will automatically be called on this component
 * when a property value changes such that size, location, or
 * internal layout of this component has been affected.  This automatic
 * updating differs from the AWT because programs generally no
 * longer need to invoke <code>validate</code> to get the contents of the
 * GUI to update.
 *
 * @see java.awt.Component#invalidate
 * @see java.awt.Container#validate
 * @see #isValidateRoot
 * @see RepaintManager#addInvalidComponent
 */
public void revalidate() {
    if (getParent() == null) {
        // Note: We don't bother invalidating here as once added
        // to a valid parent invalidate will be invoked (addImpl
        // invokes addNotify which will invoke invalidate on the
        // new Component). Also, if we do add a check to isValid
        // here it can potentially be called before the constructor
        // which was causing some people grief.
        return;
    }
    if (SunToolkit.isDispatchThreadForAppContext(this)) {
        invalidate();
        RepaintManager.currentManager(this).addInvalidComponent(this);
    }
    else {
        // To avoid a flood of Runnables when constructing GUIs off
        // the EDT, a flag is maintained as to whether or not
        // a Runnable has been scheduled.
        if (revalidateRunnableScheduled.getAndSet(true)) {
            return;
        }
        SunToolkit.executeOnEventHandlerThread(this, () -> {
            revalidateRunnableScheduled.set(false);
            revalidate();
        });
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:53,代码来源:JComponent.java


注:本文中的sun.awt.SunToolkit.isDispatchThreadForAppContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。