当前位置: 首页>>代码示例>>Java>>正文


Java SunToolkit.getContainingWindow方法代码示例

本文整理汇总了Java中sun.awt.SunToolkit.getContainingWindow方法的典型用法代码示例。如果您正苦于以下问题:Java SunToolkit.getContainingWindow方法的具体用法?Java SunToolkit.getContainingWindow怎么用?Java SunToolkit.getContainingWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.awt.SunToolkit的用法示例。


在下文中一共展示了SunToolkit.getContainingWindow方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: markClearGlobalFocusOwner

import sun.awt.SunToolkit; //导入方法依赖的package包/类
/**
 * Returns the Window which will be active after processing this request,
 * or null if this is a duplicate request. The active Window is useful
 * because some native platforms do not support setting the native focus
 * owner to null. On these platforms, the obvious choice is to set the
 * focus owner to the focus proxy of the active Window.
 */
static Window markClearGlobalFocusOwner() {
    // need to call this out of synchronized block to avoid possible deadlock
    // see 6454631.
    final Component nativeFocusedWindow =
            getCurrentKeyboardFocusManager().getNativeFocusedWindow();

    synchronized (heavyweightRequests) {
        HeavyweightFocusRequest hwFocusRequest = getLastHWRequest();
        if (hwFocusRequest ==
            HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER)
        {
            // duplicate request
            return null;
        }

        heavyweightRequests.add
            (HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER);

        Component activeWindow = ((hwFocusRequest != null)
            ? SunToolkit.getContainingWindow(hwFocusRequest.heavyweight)
            : nativeFocusedWindow);
        while (activeWindow != null &&
               !((activeWindow instanceof Frame) ||
                 (activeWindow instanceof Dialog)))
        {
            activeWindow = activeWindow.getParent_NoClientCode();
        }

        return (Window) activeWindow;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:KeyboardFocusManager.java

示例2: focusedWindowChanged

import sun.awt.SunToolkit; //导入方法依赖的package包/类
private static boolean focusedWindowChanged(Component to, Component from) {
    Window wto = SunToolkit.getContainingWindow(to);
    Window wfrom = SunToolkit.getContainingWindow(from);
    if (wto == null && wfrom == null) {
        return true;
    }
    if (wto == null) {
        return true;
    }
    if (wfrom == null) {
        return true;
    }
    return (wto != wfrom);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:KeyboardFocusManager.java

示例3: isTemporary

import sun.awt.SunToolkit; //导入方法依赖的package包/类
private static boolean isTemporary(Component to, Component from) {
    Window wto = SunToolkit.getContainingWindow(to);
    Window wfrom = SunToolkit.getContainingWindow(from);
    if (wto == null && wfrom == null) {
        return false;
    }
    if (wto == null) {
        return true;
    }
    if (wfrom == null) {
        return false;
    }
    return (wto != wfrom);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:KeyboardFocusManager.java

示例4: disposeImpl

import sun.awt.SunToolkit; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
protected void disposeImpl() {
    // TODO: we should somehow reset the listener when the choice
    // is moved to another toplevel without destroying its peer.
    Window parentWindow = SunToolkit.getContainingWindow((Component)target);
    if (parentWindow != null) {
        WWindowPeer wpeer = (WWindowPeer)parentWindow.getPeer();
        if (wpeer != null) {
            wpeer.removeWindowListener(windowListener);
        }
    }
    super.disposeImpl();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:WChoicePeer.java

示例5: disposeImpl

import sun.awt.SunToolkit; //导入方法依赖的package包/类
@Override
protected void disposeImpl() {
    // TODO: we should somehow reset the listener when the choice
    // is moved to another toplevel without destroying its peer.
    Window parentWindow = SunToolkit.getContainingWindow((Component)target);
    if (parentWindow != null) {
        final WWindowPeer wpeer = AWTAccessor.getComponentAccessor()
                                            .getPeer(parentWindow);
        if (wpeer != null) {
            wpeer.removeWindowListener(windowListener);
        }
    }
    super.disposeImpl();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:WChoicePeer.java

示例6: altReleased

import sun.awt.SunToolkit; //导入方法依赖的package包/类
void altReleased(KeyEvent ev) {
    if (menuCanceledOnPress) {
        WindowsLookAndFeel.setMnemonicHidden(true);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        return;
    }

    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    if (msm.getSelectedPath().length == 0) {
        // if no menu is active, we try activating the menubar

        JMenuBar mbar = root != null ? root.getJMenuBar() : null;
        if(mbar == null && winAncestor instanceof JFrame) {
            mbar = ((JFrame)winAncestor).getJMenuBar();
        }
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;

        // It might happen that the altRelease event is processed
        // with a reasonable delay since it has been generated.
        // Here we check the last deactivation time of the containing
        // window. If this time appears to be greater than the altRelease
        // event time the event is skipped to avoid unexpected menu
        // activation. See 7121442.
        // Also we must ensure that original source of key event belongs
        // to the same window object as winAncestor. See 8001633.
        boolean skip = false;
        Toolkit tk = Toolkit.getDefaultToolkit();
        if (tk instanceof SunToolkit) {
            Component originalSource = AWTAccessor.getKeyEventAccessor()
                    .getOriginalSource(ev);
            skip = SunToolkit.getContainingWindow(originalSource) != winAncestor ||
                    ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor);
        }

        if (menu != null && !skip) {
            MenuElement[] path = new MenuElement[2];
            path[0] = mbar;
            path[1] = menu;
            msm.setSelectedPath(path);
        } else if(!WindowsLookAndFeel.isMnemonicHidden()) {
            WindowsLookAndFeel.setMnemonicHidden(true);
            WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        }
    } else {
        if((msm.getSelectedPath())[0] instanceof ComboPopup) {
            WindowsLookAndFeel.setMnemonicHidden(true);
            WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        }
    }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:53,代码来源:WindowsRootPaneUI.java

示例7: getGraphics

import sun.awt.SunToolkit; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public Graphics getGraphics() {
    if (isDisposed()) {
        return null;
    }

    Component target = (Component)getTarget();
    Window window = SunToolkit.getContainingWindow(target);
    if (window != null) {
        Graphics g =
            ((WWindowPeer)window.getPeer()).getTranslucentGraphics();
        // getTranslucentGraphics() returns non-null value for non-opaque windows only
        if (g != null) {
            // Non-opaque windows do not support heavyweight children.
            // Redirect all painting to the Window's Graphics instead.
            // The caller is responsible for calling the
            // WindowPeer.updateWindow() after painting has finished.
            int x = 0, y = 0;
            for (Component c = target; c != window; c = c.getParent()) {
                x += c.getX();
                y += c.getY();
            }

            g.translate(x, y);
            g.clipRect(0, 0, target.getWidth(), target.getHeight());

            return g;
        }
    }

    SurfaceData surfaceData = this.surfaceData;
    if (surfaceData != null) {
        /* Fix for bug 4746122. Color and Font shouldn't be null */
        Color bgColor = background;
        if (bgColor == null) {
            bgColor = SystemColor.window;
        }
        Color fgColor = foreground;
        if (fgColor == null) {
            fgColor = SystemColor.windowText;
        }
        Font font = this.font;
        if (font == null) {
            font = defaultFont;
        }
        ScreenUpdateManager mgr =
            ScreenUpdateManager.getInstance();
        return mgr.createGraphics(surfaceData, this, fgColor,
                                  bgColor, font);
    }
    return null;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:54,代码来源:WComponentPeer.java

示例8: requestFocus

import sun.awt.SunToolkit; //导入方法依赖的package包/类
@Override
public boolean requestFocus(Component lightweightChild, boolean temporary,
                            boolean focusedWindowChangeAllowed, long time,
                            FocusEvent.Cause cause)
{
    if (WKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = WKeyboardFocusManagerPeer
        .shouldNativelyFocusHeavyweight((Component)target, lightweightChild,
                                        temporary, focusedWindowChangeAllowed,
                                        time, cause);

    switch (result) {
      case WKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case WKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " + lightweightChild + " in " + target);
          }
          Window parentWindow = SunToolkit.getContainingWindow((Component)target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          final WWindowPeer wpeer = AWTAccessor.getComponentAccessor()
                                               .getPeer(parentWindow);
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          boolean res = wpeer.requestWindowFocus(cause);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return WKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);

      case WKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:56,代码来源:WComponentPeer.java

示例9: getContainingWindow

import sun.awt.SunToolkit; //导入方法依赖的package包/类
/**
 * Returns the <code>Window</code> ancestor of the component.
 * @return Window ancestor of the component or component by itself if it is Window;
 *         null, if component is not a part of window hierarchy
 */
Window getContainingWindow() {
    return SunToolkit.getContainingWindow(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:Component.java

示例10: getContainingWindow

import sun.awt.SunToolkit; //导入方法依赖的package包/类
/**
 * Returns the {@code Window} ancestor of the component.
 * @return Window ancestor of the component or component by itself if it is Window;
 *         null, if component is not a part of window hierarchy
 */
Window getContainingWindow() {
    return SunToolkit.getContainingWindow(this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:Component.java


注:本文中的sun.awt.SunToolkit.getContainingWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。