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


Java Container.isAncestorOf方法代碼示例

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


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

示例1: waitForComponentOrChildToGetFocus

import java.awt.Container; //導入方法依賴的package包/類
public static Component waitForComponentOrChildToGetFocus(Container c) {
    Component foc = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    int ct=0;
    while (foc == null || (foc != c && !c.isAncestorOf(foc))) {
        try {
            Thread.currentThread().sleep(100);
        } catch (Exception e ) {}
        foc = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        ct++;
        if (ct > 200) {
            break;
        }
    }
    return foc;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:ExtTestCase.java

示例2: reset

import java.awt.Container; //導入方法依賴的package包/類
/** Resets panel back after monitoring search. Implements <code>ProgressMonitor</code> interface method. */
public void reset() {
    Container container = (Container) getComponent();
    
    if(!container.isAncestorOf(getUI())) {
        container.removeAll();
        GridBagConstraints constraints = new GridBagConstraints();
        constraints.weightx = 1.0;
        constraints.weighty = 1.0;
        constraints.fill = GridBagConstraints.BOTH;
        container.add(getUI(), constraints);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:AdditionalWizardPanel.java

示例3: isKnownComponent

import java.awt.Container; //導入方法依賴的package包/類
/** See if a component is one we know about or one the current editor
 * knows about.  This affects whether we paint as if focused or not, and
 * is used to determine what kind of focus changes mean we should stop
 * editing, and what kind are ok */
@Override
protected boolean isKnownComponent(Component c) {
    boolean result = super.isKnownComponent(c);

    if (result) {
        return result;
    }

    if (c == null) {
        return false;
    }

    if (c instanceof ButtonPanel) {
        return true;
    }

    InplaceEditor ie = getEditor().getInplaceEditor();

    if (ie != null) {
        JComponent comp = ie.getComponent();

        if (comp == c) {
            return true;
        }

        if (comp.isAncestorOf(c)) {
            return true;
        }
    }

    if (c.getParent() instanceof ButtonPanel) {
        return true;
    }

    if ((getParent() != null) && (getParent().isAncestorOf(c))) {
        return true;
    }

    Container par = getParent();

    if ((par != null) && par.isAncestorOf(c)) {
        return true;
    }

    if (c instanceof InplaceEditor) {
        return true;
    }

    InplaceEditor ine = getEditor().getInplaceEditor();

    if (ine != null) {
        return ine.isKnownComponent(c);
    }

    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:61,代碼來源:SheetTable.java

示例4: checkFocusedContainer

import java.awt.Container; //導入方法依賴的package包/類
/** Determine if a container or its child has focus.  If it is a window,
 * it must be the focused window */
protected static boolean checkFocusedContainer(Container c) throws Exception {
    synchronized (c.getTreeLock()) {
        c.getTreeLock().notifyAll();
    }
    if (SwingUtilities.isEventDispatchThread()) {
        //If the hide action is pending, allow it to happen before
        //checking if something happened
        drainEventQueue();
    } else {
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                try {
                    drainEventQueue();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        });
    }
    Toolkit.getDefaultToolkit().sync();
    
    //Here we're waiting for the native window system to do *its* focus
    //transferring.  So do some extra waiting - otherwise sometimes focus
    //hasn't arrived at the frame and the events handled by AWT
    sleep();
    sleep();
    sleep();
    sleep();
    sleep();
    
    Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
    Component currowner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    Component permowner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
    
    if (w == null) {
        return false;
    }
    
    if (w.isAncestorOf(currowner)) {
        //believe it or not this happens
        if (c instanceof Window && w != c) {
            System.err.println("Focused window is " + w);
            return false;
        }
    }
    if (c.isAncestorOf(currowner)) {
        return true;
    }
    if (c.isAncestorOf(permowner)) {
        return true;
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:56,代碼來源:ExtTestCase.java


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