当前位置: 首页>>代码示例>>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;未经允许,请勿转载。