Package java.awt.event

Examples of java.awt.event.AWTEventListener


            equalizerFrame = null;
        }

        // Global AWT key handler, you're better off using Swing's InputMap and
        // ActionMap with a JFrame - that would solve all sorts of focus issues too
        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
            @Override
            public void eventDispatched(AWTEvent event) {
                if(event instanceof KeyEvent) {
                    KeyEvent keyEvent = (KeyEvent)event;
                    if(keyEvent.getID() == KeyEvent.KEY_PRESSED) {
View Full Code Here


   *
   * @param e the event dispatched in the AWT.
   */
  @Override
  public void eventDispatched(AWTEvent e) {
    AWTEventListener listener = listenerReference.get();
    if (listener == null) {
      dispose();
      return;
    }
    listener.eventDispatched(e);
  }
View Full Code Here

    assertThatListenerIsUnderMask(CONTEXT_MONITOR_EVENT_MASK, ContextMonitor.class);
    assertThatListenerIsUnderMask(WINDOWS_AVAILABILITY_MONITOR_EVENT_MASK, WindowAvailabilityMonitor.class);
  }

  private void assertThatListenerIsUnderMask(long mask, Class<? extends AWTEventListener> type) {
    AWTEventListener listener = listenerUnderMask(mask);
    assertThat(listener).isInstanceOf(type);
  }
View Full Code Here

  private EventNormalizer normalizer;

  public InputState(@Nonnull Toolkit toolkit) {
    long mask = MOUSE_MOTION_EVENT_MASK | MOUSE_EVENT_MASK | KEY_EVENT_MASK;
    AWTEventListener listener = new EventDispatchThreadedEventListener() {
      @Override
      protected void processEvent(@Nonnull AWTEvent event) {
        update(event);
      }
    };
View Full Code Here

  try {
    /* Call registerListeners() to make XEmbed focus traversal work */
    Method method = clazz.getMethod("registerListeners", null);
    if (method != null) method.invoke(value, null);
  } catch (Throwable e) {}
  final AWTEventListener awtListener = new AWTEventListener() {
    public void eventDispatched(AWTEvent event) {
      if (event.getID() == WindowEvent.WINDOW_OPENED) {
        final Window window = (Window) event.getSource();
        if (window.getParent() == frame) {
          parent.getDisplay().asyncExec(new Runnable() {
View Full Code Here

        } catch (AWTException ex) {
          System.err.println("TrayIcon could not be added.");
        }
      }
    });
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
      public void eventDispatched(AWTEvent event) {
        if(event instanceof KeyEvent && event.getID() == KeyEvent.KEY_RELEASED) {
          if(DialogUtility.isWaitDialogOn()) {
            return;
          }
View Full Code Here

  {
    try {
      Toolkit toolkit = Toolkit.getDefaultToolkit();
      toolkit.getSystemEventQueue();

      AWTEventListener listener = new TestEventListener();

      Frame frame = new Frame();
      Properties props = new Properties();
      JobAttributes jobattrs = new JobAttributes();
      PageAttributes pageattrs = new PageAttributes();
View Full Code Here

  try {
    /* Call registerListeners() to make XEmbed focus traversal work */
    Method method = clazz.getMethod("registerListeners", null);
    if (method != null) method.invoke(value, null);
  } catch (Throwable e) {}
  final AWTEventListener awtListener = new AWTEventListener() {
    public void eventDispatched(AWTEvent event) {
      if (event.getID() == WindowEvent.WINDOW_OPENED) {
        final Window window = (Window) event.getSource();
        if (window.getParent() == frame) {
          parent.getDisplay().asyncExec(new Runnable() {
View Full Code Here

        } catch (Exception e) {
        }
       
        // Registers a mouse event listener to keep mouse activity within the the
        // picture panel while in line drawing mode.
        Toolkit.getDefaultToolkit().addAWTEventListener( new AWTEventListener() {
            public void eventDispatched(AWTEvent e) {
                if (pictureFrame.isSelected()) {
                    MouseEvent mouseEvent = (MouseEvent)e;
                   
                    // If a line is being drawn and the mouse event is outside the picture...
View Full Code Here

        if (exitOnClose) {
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
       
        //create the event handler for key preview functionality
        keyEventListener = new AWTEventListener() {
            public void eventDispatched(AWTEvent aWTEvent) {
                if (aWTEvent instanceof KeyEvent) {
                    KeyEvent evt = (KeyEvent)aWTEvent;
                    for (KeyListener kl : getKeyListeners()) {
                        int id = aWTEvent.getID();
                        switch (id) {
                            case KeyEvent.KEY_PRESSED:
                                kl.keyPressed(evt);
                                break;
                            case KeyEvent.KEY_RELEASED:
                                kl.keyReleased(evt);
                                break;
                            case KeyEvent.KEY_TYPED:
                                kl.keyTyped(evt);
                                break;
                            default:
                                System.err.println("Unhandled Key ID: " + id);   
                        }
                    }
                }
            }
        };
       
        idleTimer = new Timer(100, new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                setIdle(true);
            }
        });
       
        //create the event handler for key preview functionality
        idleListener = new AWTEventListener() {
            public void eventDispatched(AWTEvent aWTEvent) {
                //reset the timer
                idleTimer.stop();
                //if the user is idle, then change to not idle
                if (isIdle()) {
View Full Code Here

TOP

Related Classes of java.awt.event.AWTEventListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.