當前位置: 首頁>>代碼示例>>Java>>正文


Java EventQueue.getNextEvent方法代碼示例

本文整理匯總了Java中java.awt.EventQueue.getNextEvent方法的典型用法代碼示例。如果您正苦於以下問題:Java EventQueue.getNextEvent方法的具體用法?Java EventQueue.getNextEvent怎麽用?Java EventQueue.getNextEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.EventQueue的用法示例。


在下文中一共展示了EventQueue.getNextEvent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dispatchNextGuiEvent

import java.awt.EventQueue; //導入方法依賴的package包/類
/**
 * Processes the next GUI event.
 */
public void dispatchNextGuiEvent() throws InterruptedException {
    EventQueue queue = awtEventQueue;
    if (queue == null) {
        queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
        awtEventQueue = queue;
    }
    AWTEvent event = queue.getNextEvent();
    if (event instanceof ActiveEvent) {
        ((ActiveEvent)event).dispatch();
    } else {
        Object source = event.getSource();
        if (source instanceof Component) {
            Component comp = (Component)source;
            comp.dispatchEvent(event);
        } else if (source instanceof MenuComponent) {
            ((MenuComponent)source).dispatchEvent(event);
        }
    }
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:23,代碼來源:SwingGui.java

示例2: drainEventQueue

import java.awt.EventQueue; //導入方法依賴的package包/類
/** Drain the event queue.  ONLY CALL THIS METHOD FROM THE EVENT DISPATCH
 * THREAD OR IT WILL DO BAD THINGS! */
private static void drainEventQueue() throws Exception {
    AWTEvent evt = EventQueue.getCurrentEvent();
    //Dispatch any events that the code that just ran may have generated,
    //so dialogs appear, things get focus and paint, stuff like that
    while (Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent() != null) {
        //do fetch this every time, its value can change
        EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
        evt = queue.getNextEvent();
        dispatchEvent(queue, evt);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:ExtTestCase.java

示例3: setVisible

import java.awt.EventQueue; //導入方法依賴的package包/類
@Override
public void setVisible(boolean visible) {
	boolean blockParent = (visible && modal);
	owner.setEnabled(!blockParent);
	owner.setFocusableWindowState(!blockParent);
	super.setVisible(visible);

	if (blockParent) {
		owner.addWindowListener(parentWindowListener);
		try {
			if (SwingUtilities.isEventDispatchThread()) {
				EventQueue theQueue = getToolkit().getSystemEventQueue();
				while (isVisible()) {
					AWTEvent event = theQueue.getNextEvent();
					Object src = event.getSource();
					if (event instanceof ActiveEvent) {
						((ActiveEvent) event).dispatch();
					} else if (src instanceof Component) {
						((Component) src).dispatchEvent(event);
					}
				}
			} else {
				synchronized (getTreeLock()) {
					while (isVisible()) {
						try {
							getTreeLock().wait();
						} catch (InterruptedException e) {
							break;
						}
					}
				}
			}
		}
		catch (Exception ex) {
			ex.printStackTrace();
		}
	} else {
		owner.removeWindowListener(parentWindowListener);
		// added 2 lines
		owner.setEnabled(true);
		owner.setFocusableWindowState(true);
	}
}
 
開發者ID:igr,項目名稱:swingspy,代碼行數:44,代碼來源:CaddyDialog.java


注:本文中的java.awt.EventQueue.getNextEvent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。