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


Java WindowEvent.WINDOW_GAINED_FOCUS屬性代碼示例

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


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

示例1: trackEvent

private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) {
    EventListener listener = null;

    switch (eventID) {
    case WindowEvent.WINDOW_GAINED_FOCUS:
        listener = wgfListener;
        break;
    case FocusEvent.FOCUS_GAINED:
        listener = fgListener;
        break;
    case ActionEvent.ACTION_PERFORMED:
        listener = apListener;
        break;
    }

    listener.listen(comp, printEvent);
    action.run();
    return Util.waitForCondition(listener.getNotifier(), time);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:Util.java

示例2: handleWmTakeFocus

private void handleWmTakeFocus(XClientMessageEvent cl) {
    if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
        focusLog.fine("WM_TAKE_FOCUS on {0}", this);
    }

    if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
        // JDK-8159460
        Window focusedWindow = XKeyboardFocusManagerPeer.getInstance()
                .getCurrentFocusedWindow();
        Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
        if (activeWindow != target) {
            requestWindowFocus(cl.get_data(1), true);
        } else {
            WindowEvent we = new WindowEvent(focusedWindow,
                    WindowEvent.WINDOW_GAINED_FOCUS);
            sendEvent(we);
        }
    } else {
        requestWindowFocus(cl.get_data(1), true);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:XDecoratedPeer.java

示例3: handleWindowFocusIn_Dispatch

public void handleWindowFocusIn_Dispatch() {
    if (EventQueue.isDispatchThread()) {
        XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
        WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
        SunToolkit.setSystemGenerated(we);
        target.dispatchEvent(we);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:XWindowPeer.java

示例4: 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

示例5: handleWindowFocusInSync

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

示例6: handleWindowFocusIn

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

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