3 回答
TA贡献1862条经验 获得超7个赞
EventQueue有一个名为push()的方法,可以完全按照你想要的方式执行。这是一个小小的演示:
public class QueueTest { public static void main(String[] args) throws InterruptedException, InvocationTargetException { EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); eventQueue.push(new MyEventQueue()); EventQueue.invokeAndWait(new Runnable() { public void run() { System.out.println("Run"); } }); } private static class MyEventQueue extends EventQueue { public void postEvent(AWTEvent theEvent) { System.out.println("Event Posted"); super.postEvent(theEvent); } }}
TA贡献1796条经验 获得超7个赞
这可以。扩展EventQueue将为您提供所有AWTEvents的处理。
您将如何处理所有事件。活动清单如下。
[AWTEvent,BeanContextEvent,CaretEvent,ChangeEvent,ConnectionEvent,DragGestureEvent,DragSourceEvent,DropTargetEvent,FlavorEvent,HandshakeCompletedEvent,HyperlinkEvent,LineEvent,ListDataEvent,ListSelectionEvent,MenuEvent,NamingEvent,NamingExceptionEvent,NodeChangeEvent,Notification,PopupMenuEvent,PreferenceChangeEvent,PrintEvent,PropertyChangeEvent,RowSetEvent,RowSorterEvent ,SSLSessionBindingEvent,StatementEvent,TableColumnModelEvent,TableModelEvent,TreeExpansionEvent,TreeModelEvent,TreeSelectionEvent,UndoableEditEvent,UnsolicitedNotificationEvent]
添加回答
举报