本文整理汇总了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();
});
}
}