Package java.awt.event

Examples of java.awt.event.FocusEvent


    }

    public void testToolBarFocusListener() {
        toolBar.add(b);
        FocusListener l = ui.createToolBarFocusListener();
        FocusEvent e = new FocusEvent(b, FocusEvent.FOCUS_GAINED);
        l.focusGained(e);
        assertEquals(toolBar.getComponentIndex(b), ui.focusedCompIndex);
    }
View Full Code Here


  public final void setFocused(final boolean focused) {
    if (focused && !this.focused) {
      // null opposite; permanent gain, as expected when entire Applet
      // regains focus
      super.processEvent(new FocusEvent(this, FocusEvent.FOCUS_GAINED, false, null));
    } else if (this.focused) {
      // null opposite; temporary loss, as expected when entire Applet
      // loses focus
      super.processEvent(new FocusEvent(this, FocusEvent.FOCUS_LOST, true, null));
    }
    this.focused = focused;
  }
View Full Code Here

        case SWT.Activate:
          EventQueue.invokeLater(new Runnable () {
            public void run () {
              if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 4, 0)) {
                frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ACTIVATED));
                frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_GAINED));
              } else if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 5, 0)) {
                frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ACTIVATED));
                frame.dispatchEvent (new WindowEvent (frame, 207 /*WindowEvent.WINDOW_GAINED_FOCUS*/));
              } else {
                if (frame.isActive()) return;
                try {
                  Class clazz = frame.getClass();
                  Method method = clazz.getMethod("synthesizeWindowActivation", new Class[]{boolean.class});
                  if (method != null) method.invoke(frame, new Object[]{new Boolean(true)});
                } catch (Throwable e) {}
              }
            }
          });
          break;
        case SWT.Deactivate:
          EventQueue.invokeLater(new Runnable () {
            public void run () {
              if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 4, 0)) {
                frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEACTIVATED));
                frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_LOST));
              } else if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 5, 0)) {
                frame.dispatchEvent (new WindowEvent (frame, 208 /*WindowEvent.WINDOW_LOST_FOCUS*/));
                frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEACTIVATED));
              } else {
                if (!frame.isActive()) return;
View Full Code Here

        case SWT.Activate:
          EventQueue.invokeLater(new Runnable () {
            public void run () {
              if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 4, 0)) {
                frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ACTIVATED));
                frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_GAINED));
              } else if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 5, 0)) {
                frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ACTIVATED));
                frame.dispatchEvent (new WindowEvent (frame, 207 /*WindowEvent.WINDOW_GAINED_FOCUS*/));
              } else {
                if (frame.isActive()) return;
                try {
                  Class clazz = frame.getClass();
                  Method method = clazz.getMethod("synthesizeWindowActivation", new Class[]{boolean.class});
                  if (method != null) method.invoke(frame, new Object[]{new Boolean(true)});
                } catch (Throwable e) {}
              }
            }
          });
          break;
        case SWT.Deactivate:
          EventQueue.invokeLater(new Runnable () {
            public void run () {
              if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 4, 0)) {
                frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEACTIVATED));
                frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_LOST));
              } else if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 5, 0)) {
                frame.dispatchEvent (new WindowEvent (frame, 208 /*WindowEvent.WINDOW_LOST_FOCUS*/));
                frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEACTIVATED));
              } else {
                if (!frame.isActive()) return;
View Full Code Here

  }
 
  private void focus() {
    FocusListener[] listeners = textField.getFocusListeners();
    for (int i = 0; i < listeners.length; i++) {
      listeners[i].focusGained(new FocusEvent(textField, FocusEvent.FOCUS_GAINED));
    }
  }
View Full Code Here

  }
 
  private void removeFocus() {
    FocusListener[] listeners = textField.getFocusListeners();
    for (int i = 0; i < listeners.length; i++) {
      listeners[i].focusLost(new FocusEvent(textField, FocusEvent.FOCUS_LOST));
    }
  }
View Full Code Here

   }
   eDriver.dispatchEvent(oper.getSource(),
            new WindowEvent((Window)oper.getSource(),
                WindowEvent.WINDOW_ACTIVATED));
   eDriver.dispatchEvent(oper.getSource(),
            new FocusEvent((Window)oper.getSource(),
                                             FocusEvent.FOCUS_GAINED));
    }
View Full Code Here

  eDriver = new EventDriver();
    }
    public void giveFocus(ComponentOperator operator) {
  operator.requestFocus();
  eDriver.dispatchEvent(operator.getSource(),
            new FocusEvent(operator.getSource(),
               FocusEvent.FOCUS_GAINED));
    }
View Full Code Here

                    if ( event instanceof FocusEvent )
                    {
                        if ( globalFocusListeners.size () > 0 )
                        {
                            // Filtering unnecessary events (each focus change within application generates 2 events - lost/gained)
                            final FocusEvent focusEvent = ( FocusEvent ) event;
                            if ( focusEvent.getID () == FocusEvent.FOCUS_LOST && focusEvent.getOppositeComponent () == null )
                            {
                                // Focus moved outside the application
                                fireGlobalFocusChanged ( focusEvent.getComponent (), null );
                            }
                            else if ( focusEvent.getID () == FocusEvent.FOCUS_GAINED )
                            {
                                // Focus changed within the application (or might have just entered the window)
                                fireGlobalFocusChanged ( focusEvent.getOppositeComponent (), focusEvent.getComponent () );
                            }
                        }
                    }
                }
            }, AWTEvent.FOCUS_EVENT_MASK );
View Full Code Here

        redispatchEvent(target, e);
        return true;
      }
    else if (e instanceof FocusEvent)
      {
        FocusEvent fe = (FocusEvent) e;
        Component target = fe.getComponent ();

        boolean retval = false;
        if (e.id == FocusEvent.FOCUS_GAINED)
          {
            retval = handleFocusGained(fe);
View Full Code Here

TOP

Related Classes of java.awt.event.FocusEvent

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.