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


Java AWTEventListener類代碼示例

本文整理匯總了Java中java.awt.event.AWTEventListener的典型用法代碼示例。如果您正苦於以下問題:Java AWTEventListener類的具體用法?Java AWTEventListener怎麽用?Java AWTEventListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: whetherMenusAreAccessible

import java.awt.event.AWTEventListener; //導入依賴的package包/類
@Override public void whetherMenusAreAccessible() throws Throwable {
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override public void eventDispatched(AWTEvent event) {
            System.err.println(event);
        }
    }, AWTEvent.KEY_EVENT_MASK);
    if (Platform.getCurrent() == Platform.MAC && System.getProperty("java.version", "").matches("1.[78].*")) {
        throw new SkipException("Menu mneomonics are not handled on Mac under Java 1.7+");
    }
    exitItemCalled = false;
    driver.sendKeys(textField, JavaAgentKeys.chord(JavaAgentKeys.ALT, "f"));
    new WaitWithoutException("Waiting for exit item to be shown") {
        @Override public boolean until() {
            return exitItem.isShowing();
        }
    };
    driver.click(exitItem, Buttons.LEFT, 1, 0, 0);
    new WaitWithoutException("Waiting for exit item to be called") {
        @Override public boolean until() {
            return exitItemCalled;
        }
    };
    AssertJUnit.assertEquals(true, exitItemCalled);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:25,代碼來源:EventQueueDeviceKBTest.java

示例2: isLayerEventControllerAdded

import java.awt.event.AWTEventListener; //導入依賴的package包/類
static boolean isLayerEventControllerAdded() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    AWTEventListener layerEventController = null;
    for (AWTEventListener listener : toolkit.getAWTEventListeners()) {
        if (listener instanceof AWTEventListenerProxy) {
            listener = ((AWTEventListenerProxy)listener).getListener();

        }
        if ("LayerEventController".equals(listener.getClass().getSimpleName())) {
            if (layerEventController != null) {
                throw new RuntimeException("Duplicated LayerEventController");
            }
            layerEventController = listener;
        }
    }
    boolean ret = layerEventController != null;
    if (ret) {
        System.out.println("LayerEventController found");
    } else {
        System.out.println("No LayerEventController");
    }
    return ret;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:bug6872503.java

示例3: layerEventControllerMaskEquals

import java.awt.event.AWTEventListener; //導入依賴的package包/類
static boolean layerEventControllerMaskEquals(long mask) {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    AWTEventListener layerEventController = null;
    for (AWTEventListener listener : toolkit.getAWTEventListeners(mask)) {
        if (listener instanceof AWTEventListenerProxy) {
            listener = ((AWTEventListenerProxy)listener).getListener();

        }
        if ("LayerEventController".equals(listener.getClass().getSimpleName())) {
            if (layerEventController != null) {
                throw new RuntimeException("Duplicated LayerEventController");
            }
            layerEventController = listener;
        }
    }
    boolean ret = layerEventController != null;
    if (ret) {
        System.out.println("LayerEventController with the correct mask found");
    } else {
        System.out.println("No LayerEventController with the correct mask");
    }
    return ret;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:bug6872503.java

示例4: installDebugHotkey

import java.awt.event.AWTEventListener; //導入依賴的package包/類
/** Install a debugging hotkey.  When that key is pressed: a new
 * <code>GraphicsWriterDebugger</code> frame will appear that paints
 * the argument.
 * 
 * @param component a component to debug.  The <code>paint()</code> method
 * of this argument will be used.
 * @param keyCode a <code>KeyEven.VK_X</code> key code.  When this key is
 * pressed, the <code>GraphicsWriterDebugger</code> frame will be created.
 */
public static void installDebugHotkey(final Component component,final int keyCode) {
	Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {

		public void eventDispatched(AWTEvent event) {
			KeyEvent e = (KeyEvent)event;
			if(e.getKeyCode()==keyCode && e.getID()==KeyEvent.KEY_PRESSED) {
				GraphicsWriter writer = new GraphicsWriter(true);
				component.paint(writer);
				GraphicsWriterDebugger d = new GraphicsWriterDebugger(writer);
				d.pack();
				d.setVisible(true);
			}
		}
		
	}, AWTEvent.KEY_EVENT_MASK);
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:26,代碼來源:GraphicsWriterDebugger.java

示例5: adjustFocusTraversal

import java.awt.event.AWTEventListener; //導入依賴的package包/類
public static void adjustFocusTraversal(@NotNull Disposable disposable) {
  if (!SystemInfo.isMacOSSnowLeopard) return;
  final AWTEventListener listener = new AWTEventListener() {
    @Override
    public void eventDispatched(AWTEvent event) {
      if (event instanceof KeyEvent
          && ((KeyEvent)event).getKeyCode() == KeyEvent.VK_TAB
          && (!(event.getSource() instanceof JTextComponent))
          && (!(event.getSource() instanceof JList))
          && !isFullKeyboardAccessEnabled())
        ((KeyEvent)event).consume();
    }
  };
  Disposer.register(disposable, new Disposable() {
    @Override
    public void dispose() {
      Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
    }
  });
  Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.KEY_EVENT_MASK);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:MacUtil.java

示例6: CHelpManager

import java.awt.event.AWTEventListener; //導入依賴的package包/類
/**
 * Creates a new help manager object.
 */
private CHelpManager()
{
	final Image cursorImage = Toolkit.getDefaultToolkit().getImage(CMain.class.getResource("data/help.png"));
	final java.awt.Point cursorHotSpot = new java.awt.Point(0,0);
	m_helpCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImage, cursorHotSpot, "helpCursor");

	Toolkit.getDefaultToolkit().addAWTEventListener( new AWTEventListener()
	{
		@Override
		public void eventDispatched(final AWTEvent event)
		{
			handleEvent(event);
		}
	},
	AWTEvent.MOUSE_EVENT_MASK);
}
 
開發者ID:google,項目名稱:binnavi,代碼行數:20,代碼來源:CHelpManager.java

示例7: startTracking

import java.awt.event.AWTEventListener; //導入依賴的package包/類
/**
 * Start tracking activity (globally currently only mouse activity, inside
 * of the program keypresses and mouse actions).
 */
public static void startTracking() {
    if (timer == null) {
        checkMouseLocation();
        timer = new Timer(DELAY, new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                checkMouseLocation();
            }
        });
        timer.start();
        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {

            @Override
            public void eventDispatched(AWTEvent event) {
                triggerActivity();
            }
        }, AWTEvent.KEY_EVENT_MASK + AWTEvent.MOUSE_EVENT_MASK);
        LOGGER.info("Started tracking user activity..");
    }
}
 
開發者ID:chatty,項目名稱:chatty,代碼行數:26,代碼來源:ActivityTracker.java

示例8: start

import java.awt.event.AWTEventListener; //導入依賴的package包/類
public static void start() {
	if (properties == null)
		properties = new ScreenShotProperties();

	listener = new AWTEventListener() {
		@Override
		public void eventDispatched(AWTEvent event) {
			if (active && properties.useHotkey &&
					((KeyEvent)event).getKeyCode() == KeyEvent.VK_PRINTSCREEN &&
					event.getID() == KeyEvent.KEY_RELEASED ) {
				takeScreenshot(ScreenshotType.GAME);
				((KeyEvent)event).consume();
			}
		}
	};

	Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.KEY_EVENT_MASK);
	active = true;
}
 
開發者ID:EspeonRS,項目名稱:pegasia,代碼行數:20,代碼來源:ScreenShotPlugin.java

示例9: activateKeyStates

import java.awt.event.AWTEventListener; //導入依賴的package包/類
public static void activateKeyStates() {
	if (keyStates == null)
		keyStates = new AdvancedKeyListenerFilter(null,  false);
	// add a global listener
	Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
		public void eventDispatched(AWTEvent e) {
			if (e instanceof KeyEvent) {
				switch (e.getID()) {
				case KeyEvent.KEY_PRESSED:
					keyStates.keyPressed((KeyEvent)e);
					break;
				case KeyEvent.KEY_RELEASED:
					keyStates.keyReleased((KeyEvent)e);
					break;
				case KeyEvent.KEY_TYPED:
					keyStates.keyTyped((KeyEvent)e);
					break;
				}
			}
		}
	}, AWTEvent.KEY_EVENT_MASK);
}
 
開發者ID:mathieulegoc,項目名稱:SmartTokens,代碼行數:23,代碼來源:GUIUtils.java

示例10: initActivityMonitor

import java.awt.event.AWTEventListener; //導入依賴的package包/類
private void initActivityMonitor() {
	lastActivity = System.currentTimeMillis();
	final AWTEventListener awtEventListener = new AWTEventListener() {
		/** {@inheritDoc} */
		@Override
		public void eventDispatched(AWTEvent event) {
			lastActivity = System.currentTimeMillis();
		}
	};
	Toolkit.getDefaultToolkit().addAWTEventListener(awtEventListener,
			AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK
					| AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
	final Timer activityMonitorTimer = new Timer("ActivityMonitorTimer", true);
	final TimerTask timerTask = new TimerTask() {
		/** {@inheritDoc} */
		@Override
		public void run() {
			if (System.currentTimeMillis() - lastActivity > INACTIVITY_DELAY * 60L * 1000) {
				exit(1);
			}
		}
	};
	// on vérifie l'activité utilisateur toutes les 60 secondes par rapport au délai maximum d'inactivité
	activityMonitorTimer.schedule(timerTask, 60L * 1000, 60L * 1000);
}
 
開發者ID:javamelody,項目名稱:javamelody,代碼行數:26,代碼來源:MainFrame.java

示例11: addVideoFileListeners

import java.awt.event.AWTEventListener; //導入依賴的package包/類
private void addVideoFileListeners() {
	final long eventMask = AWTEvent.KEY_EVENT_MASK;
	final NumberKeySeekListener keyEventListener = new NumberKeySeekListener(this.videoDisplay);
	Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
		@Override
		public void eventDispatched(final AWTEvent event) {
			switch (event.getID()) {
			case KeyEvent.KEY_PRESSED:
				final KeyEvent kevent = (KeyEvent) event;
				keyEventListener.keyPressed(kevent);
				break;
			};
		}
	}, eventMask);
	//		rp.addKeyListener(new NumberKeySeekListener(videoDisplay));
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:17,代碼來源:VideoProcessingDemo.java

示例12: startMouseCapture

import java.awt.event.AWTEventListener; //導入依賴的package包/類
/**
 * Starts mouse capture.
 */
protected void startMouseCapture() throws IOException {
    mouseCaptureTimer = new ScheduledThreadPoolExecutor(1);
    int delay = max(1, (int) (1000 / mouseFormat.get(FrameRateKey).doubleValue()));
    mouseGrabber = new MouseGrabber(this, recordingStartTime, mouseCaptureTimer);
    mouseFuture = mouseCaptureTimer.scheduleAtFixedRate(mouseGrabber, delay, delay, TimeUnit.MILLISECONDS);
    final MouseGrabber mouseGrabberF = mouseGrabber;
    awtEventListener = new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent event) {
            if (event.getID() == MouseEvent.MOUSE_PRESSED) {
                mouseGrabberF.setMousePressed(true);
            } else if (event.getID() == MouseEvent.MOUSE_RELEASED) {
                mouseGrabberF.setMousePressed(false);
            }
        }
    };
    Toolkit.getDefaultToolkit().addAWTEventListener(awtEventListener, AWTEvent.MOUSE_EVENT_MASK);
    mouseGrabber.setFuture(mouseFuture);
}
 
開發者ID:pojosontheweb,項目名稱:selenium-utils,代碼行數:23,代碼來源:ScreenRecorder.java


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