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


Java WindowEvent.WINDOW_LOST_FOCUS屬性代碼示例

本文整理匯總了Java中java.awt.event.WindowEvent.WINDOW_LOST_FOCUS屬性的典型用法代碼示例。如果您正苦於以下問題:Java WindowEvent.WINDOW_LOST_FOCUS屬性的具體用法?Java WindowEvent.WINDOW_LOST_FOCUS怎麽用?Java WindowEvent.WINDOW_LOST_FOCUS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.awt.event.WindowEvent的用法示例。


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

示例1: postEvent

public static void postEvent(AppContext appContext, AWTEvent event) {
    if (event == null) {
        throw new NullPointerException();
    }

    AWTAccessor.SequencedEventAccessor sea = AWTAccessor.getSequencedEventAccessor();
    if (sea != null && sea.isSequencedEvent(event)) {
        AWTEvent nested = sea.getNested(event);
        if (nested.getID() == WindowEvent.WINDOW_LOST_FOCUS &&
            nested instanceof TimedWindowEvent)
        {
            TimedWindowEvent twe = (TimedWindowEvent)nested;
            ((SunToolkit)Toolkit.getDefaultToolkit()).
                setWindowDeactivationTime((Window)twe.getSource(), twe.getWhen());
        }
    }

    // All events posted via this method are system-generated.
    // Placing the following call here reduces considerably the
    // number of places throughout the toolkit that would
    // otherwise have to be modified to precisely identify
    // system-generated events.
    setSystemGenerated(event);
    AppContext eventContext = targetToAppContext(event.getSource());
    if (eventContext != null && !eventContext.equals(appContext)) {
        throw new RuntimeException("Event posted on wrong app context : " + event);
    }
    PostEventQueue postEventQueue =
        (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
    if (postEventQueue != null) {
        postEventQueue.postEvent(event);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:33,代碼來源:SunToolkit.java

示例2: handleWindowFocusOut

public void handleWindowFocusOut(Window oppositeWindow, long serial) {
    WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
    XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow(null);
    XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
    /* wrap in Sequenced, then post*/
    postEvent(wrapInSequenced((AWTEvent) we));
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:7,代碼來源:XWindowPeer.java

示例3: handleEvent

public void handleEvent(java.awt.AWTEvent e) {
    if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() && target.isEnabled())  {
        if (e instanceof MouseEvent) {
            if (e instanceof MouseWheelEvent) {
                handleJavaMouseWheelEvent((MouseWheelEvent) e);
            }
            else
                handleJavaMouseEvent((MouseEvent) e);
        }
        else if (e instanceof KeyEvent) {
            handleF10JavaKeyEvent((KeyEvent)e);
            handleJavaKeyEvent((KeyEvent)e);
        }
    }
    else if (e instanceof KeyEvent && !((InputEvent)e).isConsumed()) {
        // even if target is disabled.
        handleF10JavaKeyEvent((KeyEvent)e);
    }
    else if (e instanceof InputMethodEvent) {
        handleJavaInputMethodEvent((InputMethodEvent) e);
    }

    int id = e.getID();

    switch(id) {
      case PaintEvent.PAINT:
          // Got native painting
          paintPending = false;
          // Fallthrough to next statement
      case PaintEvent.UPDATE:
          // Skip all painting while layouting and all UPDATEs
          // while waiting for native paint
          if (!isLayouting && !paintPending) {
              paintArea.paint(target,false);
          }
          return;
      case FocusEvent.FOCUS_LOST:
      case FocusEvent.FOCUS_GAINED:
          handleJavaFocusEvent(e);
          break;
      case WindowEvent.WINDOW_LOST_FOCUS:
      case WindowEvent.WINDOW_GAINED_FOCUS:
          handleJavaWindowFocusEvent(e);
          break;
      default:
          break;
    }

}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:49,代碼來源:XComponentPeer.java

示例4: handleWindowFocusOutSync

public void handleWindowFocusOutSync(Window oppositeWindow, long serial) {
    WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
    XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow(null);
    XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
    sendEvent(we);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:6,代碼來源:XWindowPeer.java

示例5: handleEvent

@SuppressWarnings("fallthrough")
public void handleEvent(java.awt.AWTEvent e) {
    if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() && target.isEnabled())  {
        if (e instanceof MouseEvent) {
            if (e instanceof MouseWheelEvent) {
                handleJavaMouseWheelEvent((MouseWheelEvent) e);
            }
            else
                handleJavaMouseEvent((MouseEvent) e);
        }
        else if (e instanceof KeyEvent) {
            handleF10JavaKeyEvent((KeyEvent)e);
            handleJavaKeyEvent((KeyEvent)e);
        }
    }
    else if (e instanceof KeyEvent && !((InputEvent)e).isConsumed()) {
        // even if target is disabled.
        handleF10JavaKeyEvent((KeyEvent)e);
    }
    else if (e instanceof InputMethodEvent) {
        handleJavaInputMethodEvent((InputMethodEvent) e);
    }

    int id = e.getID();

    switch(id) {
      case PaintEvent.PAINT:
          // Got native painting
          paintPending = false;
          // Fallthrough to next statement
      case PaintEvent.UPDATE:
          // Skip all painting while layouting and all UPDATEs
          // while waiting for native paint
          if (!isLayouting && !paintPending) {
              paintArea.paint(target,false);
          }
          return;
      case FocusEvent.FOCUS_LOST:
      case FocusEvent.FOCUS_GAINED:
          handleJavaFocusEvent(e);
          break;
      case WindowEvent.WINDOW_LOST_FOCUS:
      case WindowEvent.WINDOW_GAINED_FOCUS:
          handleJavaWindowFocusEvent(e);
          break;
      default:
          break;
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:50,代碼來源:XComponentPeer.java


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