Package java.awt.event

Examples of java.awt.event.FocusEvent


    // If old focus owner != new focus owner, notify old focus
    // owner that it has lost focus.
    Component oldFocusOwner = getGlobalFocusOwner();
    if (oldFocusOwner != null && oldFocusOwner != target)
      {
        FocusEvent lost = new FocusEvent(oldFocusOwner,
                                         FocusEvent.FOCUS_LOST,
                                         fe.isTemporary(), target);
        oldFocusOwner.dispatchEvent(lost);
      }
View Full Code Here


            // bootstrapping issues.  We need to set the default
            // KeyboardFocusManager in EventQueue before the event
            // queue is started.
            EventQueue q = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
            if (focusOwner != permanentFocusOwner)
              q.postEvent (new FocusEvent (focusOwner, FocusEvent.FOCUS_LOST, true));
            else
              q.postEvent (new FocusEvent (focusOwner, FocusEvent.FOCUS_LOST, false));
          }

        if (focusOwner != permanentFocusOwner)
          {
            EventQueue q = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
            q.postEvent (new FocusEvent (permanentFocusOwner, FocusEvent.FOCUS_LOST, false));
          }
      }
  }
View Full Code Here

   */
  static AWTEvent retargetFocusEvent(AWTEvent ev)
  {
    if (ev instanceof FocusEvent)
      {
        FocusEvent fe = (FocusEvent) ev;
        Component target = fe.getComponent();
        if (focusRequests.containsKey(target))
          {
            Component lightweight = (Component) focusRequests.get(target);
            ev = new FocusEvent(lightweight, fe.id, fe.isTemporary());
            focusRequests.remove(target);
          }
      }
    return ev;
  }
View Full Code Here

    XEventHelper.addMouseMotionHandler( this, b, "mouseMotionMethod" );

    ActionEvent aEvent = new ActionEvent( b, ActionEvent.ACTION_PERFORMED, "test" );
    b.dispatchEvent( aEvent );

    FocusEvent fEvent = new FocusEvent( b, FocusEvent.FOCUS_GAINED );
    b.dispatchEvent( fEvent );

    TextEvent tEvent = new TextEvent( tf, TextEvent.TEXT_VALUE_CHANGED );
    tf.dispatchEvent( tEvent );
View Full Code Here

    actionPerformed = true;
  }

  public void focusMethod()
  {
    FocusEvent evt = (FocusEvent)getCurrentEvent();
    System.out.println( evt.getID() == evt.FOCUS_LOST );
    focusGained = true;
  }
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

   }
   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

    private class FocusOwnerListener implements WindowFocusListener {

        @Override
        public void windowGainedFocus(WindowEvent e) {
            editor.appendState(WindowElementState.ACTIVE);
            focusListener.focusGained(new FocusEvent(editorWindow, FocusEvent.FOCUS_GAINED));
        }
View Full Code Here

            }
            if (!bKeepLastOwner) {
                lastFocusRootOwner = component;
            }

            FocusEvent lostEvent = null;
            for (FocusListener lst : focusRoots.values()) {
                if (lst == getsFocus) {
                    lst.focusGained(new FocusEvent((Component) newValue, FocusEvent.FOCUS_GAINED, false, (Component) oldValue));
                } else {
                    if (lostEvent == null && previousFocusRootOwner != null) {
                        lostEvent = new FocusEvent(previousFocusRootOwner, FocusEvent.FOCUS_LOST, false,
                                        (Component) newValue);
                    }
                    lst.focusLost(lostEvent);
                }
            }
View Full Code Here

            descendant = heavyweight;
        }

        KeyboardFocusManager manager = getCurrentKeyboardFocusManager(SunToolkit.targetToAppContext(descendant));

        FocusEvent currentFocusOwnerEvent = null;
        FocusEvent newFocusOwnerEvent = null;
        Component currentFocusOwner = manager.getGlobalFocusOwner();

        synchronized (heavyweightRequests) {
            HeavyweightFocusRequest hwFocusRequest = getLastHWRequest();
            if (hwFocusRequest == null &&
                heavyweight == manager.getNativeFocusOwner() &&
                allowSyncFocusRequests)
            {

                if (descendant == currentFocusOwner) {
                    // Redundant request.
                    return true;
                }

                // 'heavyweight' owns the native focus and there are no pending
                // requests. 'heavyweight' must be a Container and
                // 'descendant' must not be the focus owner. Otherwise,
                // we would never have gotten this far.
                manager.enqueueKeyEvents(time, descendant);

                hwFocusRequest =
                    new HeavyweightFocusRequest(heavyweight, descendant,
                                                temporary, CausedFocusEvent.Cause.UNKNOWN);
                heavyweightRequests.add(hwFocusRequest);

                if (currentFocusOwner != null) {
                    currentFocusOwnerEvent =
                        new FocusEvent(currentFocusOwner,
                                       FocusEvent.FOCUS_LOST,
                                       temporary, descendant);
                }
                newFocusOwnerEvent =
                    new FocusEvent(descendant, FocusEvent.FOCUS_GAINED,
                                   temporary, currentFocusOwner);
            }
        }
        boolean result = false;
        final boolean clearing = clearingCurrentLightweightRequests;
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.