本文整理汇总了Java中sun.awt.AppContext.isDisposed方法的典型用法代码示例。如果您正苦于以下问题:Java AppContext.isDisposed方法的具体用法?Java AppContext.isDisposed怎么用?Java AppContext.isDisposed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.awt.AppContext
的用法示例。
在下文中一共展示了AppContext.isDisposed方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initContext
import sun.awt.AppContext; //导入方法依赖的package包/类
private synchronized void initContext() {
final AppContext context = AppContext.getAppContext();
if (contentsContext != context) {
// Need to synchronize on the AppContext to guarantee that it cannot
// be disposed after the check, but before the listener is added.
synchronized (context) {
if (context.isDisposed()) {
throw new IllegalStateException("Can't set contents from disposed AppContext");
}
context.addPropertyChangeListener
(AppContext.DISPOSED_PROPERTY_NAME, this);
}
if (contentsContext != null) {
contentsContext.removePropertyChangeListener
(AppContext.DISPOSED_PROPERTY_NAME, this);
}
contentsContext = context;
}
}
示例2: scheduleDisplayChanges
import sun.awt.AppContext; //导入方法依赖的package包/类
private void scheduleDisplayChanges() {
// To avoid threading problems, we notify each RepaintManager
// on the thread it was created on.
for (Object c : AppContext.getAppContexts()) {
AppContext context = (AppContext) c;
synchronized(context) {
if (!context.isDisposed()) {
EventQueue eventQueue = (EventQueue)context.get(
AppContext.EVENT_QUEUE_KEY);
if (eventQueue != null) {
eventQueue.postEvent(new InvocationEvent(
Toolkit.getDefaultToolkit(),
new DisplayChangedRunnable()));
}
}
}
}
}
示例3: scheduleDisplayChanges
import sun.awt.AppContext; //导入方法依赖的package包/类
private static void scheduleDisplayChanges() {
// To avoid threading problems, we notify each RepaintManager
// on the thread it was created on.
for (AppContext context : AppContext.getAppContexts()) {
synchronized(context) {
if (!context.isDisposed()) {
EventQueue eventQueue = (EventQueue)context.get(
AppContext.EVENT_QUEUE_KEY);
if (eventQueue != null) {
eventQueue.postEvent(new InvocationEvent(
Toolkit.getDefaultToolkit(),
new DisplayChangedRunnable()));
}
}
}
}
}
示例4: firePropertyChange
import sun.awt.AppContext; //导入方法依赖的package包/类
@Override
public void firePropertyChange(final PropertyChangeEvent evt) {
Object oldValue = evt.getOldValue();
Object newValue = evt.getNewValue();
String propertyName = evt.getPropertyName();
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
}
Runnable updater = new Runnable() {
public void run() {
PropertyChangeSupport pcs = (PropertyChangeSupport)
AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
if (null != pcs) {
pcs.firePropertyChange(evt);
}
}
};
final AppContext currentAppContext = AppContext.getAppContext();
for (AppContext appContext : AppContext.getAppContexts()) {
if (null == appContext || appContext.isDisposed()) {
continue;
}
if (currentAppContext == appContext) {
updater.run();
} else {
final PeerEvent e = new PeerEvent(source, updater, PeerEvent.ULTIMATE_PRIORITY_EVENT);
SunToolkit.postEvent(appContext, e);
}
}
}
示例5: sendMessage
import sun.awt.AppContext; //导入方法依赖的package包/类
/**
* Sends a synthetic AWTEvent to a Component. If the Component is in
* the current AppContext, then the event is immediately dispatched.
* If the Component is in a different AppContext, then the event is
* posted to the other AppContext's EventQueue, and this method blocks
* until the event is handled or target AppContext is disposed.
* Returns true if successfuly dispatched event, false if failed
* to dispatch.
*/
static boolean sendMessage(Component target, AWTEvent e) {
e.isPosted = true;
AppContext myAppContext = AppContext.getAppContext();
final AppContext targetAppContext = target.appContext;
final SentEvent se =
new DefaultKeyboardFocusManagerSentEvent(e, myAppContext);
if (myAppContext == targetAppContext) {
se.dispatch();
} else {
if (targetAppContext.isDisposed()) {
return false;
}
SunToolkit.postEvent(targetAppContext, se);
if (EventQueue.isDispatchThread()) {
EventDispatchThread edt = (EventDispatchThread)
Thread.currentThread();
edt.pumpEvents(SentEvent.ID, new Conditional() {
public boolean evaluate() {
return !se.dispatched && !targetAppContext.isDisposed();
}
});
} else {
synchronized (se) {
while (!se.dispatched && !targetAppContext.isDisposed()) {
try {
se.wait(1000);
} catch (InterruptedException ie) {
break;
}
}
}
}
}
return se.dispatched;
}
示例6: sendMessage
import sun.awt.AppContext; //导入方法依赖的package包/类
/**
* Sends a synthetic AWTEvent to a Component. If the Component is in
* the current AppContext, then the event is immediately dispatched.
* If the Component is in a different AppContext, then the event is
* posted to the other AppContext's EventQueue, and this method blocks
* until the event is handled or target AppContext is disposed.
* Returns true if successfully dispatched event, false if failed
* to dispatch.
*/
static boolean sendMessage(Component target, AWTEvent e) {
e.isPosted = true;
AppContext myAppContext = AppContext.getAppContext();
final AppContext targetAppContext = target.appContext;
final SentEvent se =
new DefaultKeyboardFocusManagerSentEvent(e, myAppContext);
if (myAppContext == targetAppContext) {
se.dispatch();
} else {
if (targetAppContext.isDisposed()) {
return false;
}
SunToolkit.postEvent(targetAppContext, se);
if (EventQueue.isDispatchThread()) {
EventDispatchThread edt = (EventDispatchThread)
Thread.currentThread();
edt.pumpEvents(SentEvent.ID, new Conditional() {
public boolean evaluate() {
return !se.dispatched && !targetAppContext.isDisposed();
}
});
} else {
synchronized (se) {
while (!se.dispatched && !targetAppContext.isDisposed()) {
try {
se.wait(1000);
} catch (InterruptedException ie) {
break;
}
}
}
}
}
return se.dispatched;
}
示例7: checkChange
import sun.awt.AppContext; //导入方法依赖的package包/类
/**
* Checks change of the {@code DataFlavor}s and, if necessary,
* posts notifications on {@code FlavorEvent}s to the
* AppContexts' EDTs.
* The parameter {@code formats} is null iff we have just
* failed to get formats available on the clipboard.
*
* @param formats data formats that have just been retrieved from
* this clipboard
*/
protected final void checkChange(final long[] formats) {
if (Arrays.equals(formats, currentFormats)) {
// we've been able to successfully get available on the clipboard
// DataFlavors this and previous time and they are coincident;
// don't notify
return;
}
currentFormats = formats;
for (final AppContext appContext : AppContext.getAppContexts()) {
if (appContext == null || appContext.isDisposed()) {
continue;
}
Set<FlavorListener> flavorListeners = getFlavorListeners(appContext);
if (flavorListeners != null) {
for (FlavorListener listener : flavorListeners) {
if (listener != null) {
PeerEvent peerEvent = new PeerEvent(this,
() -> listener.flavorsChanged(new FlavorEvent(SunClipboard.this)),
PeerEvent.PRIORITY_EVENT);
SunToolkit.postEvent(appContext, peerEvent);
}
}
}
}
}