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


Java FocusEvent.getOppositeComponent方法代碼示例

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


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

示例1: focusLost

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
public void focusLost(FocusEvent fe) {
    if ((dragListener != null) && dragListener.isDragging()) {
        dragListener.abortDrag();
    }

    PropUtils.log(BaseTable.class, fe);

    //Ignore temporary focus changes, so sloppy focus middle mouse button
    //cut/paste can work
    if (fe.isTemporary()) {
        return;
    }

    Component opposite = fe.getOppositeComponent();

    if (!isKnownComponent(opposite)) {
        doFocusLost(opposite);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:BaseTable.java

示例2: retargetUnexpectedFocusEvent

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new FocusEvent(source, fe.getID(), temporary, opposite,
                                    FocusEvent.Cause.UNEXPECTED);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:KeyboardFocusManager.java

示例3: retargetUnexpectedFocusEvent

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
                                    CausedFocusEvent.Cause.NATIVE_SYSTEM);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:KeyboardFocusManager.java

示例4: focusLost

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
@Override
public void focusLost(FocusEvent e) {
	Object dst = e.getOppositeComponent();
	if (dst instanceof Component) {
		Component p = (Component) dst;
		while (p != null && !(p instanceof Window)) {
			if (p == AttrTable.this) {
				// switch to another place in this table,
				// no problem
				return;
			}
			p = p.getParent();
		}
		// focus transferred outside table; stop editing
		editor.stopCellEditing();
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:18,代碼來源:AttrTable.java

示例5: processFocusEvent

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
/** Overridden to remove the editor on focus lost */
public void processFocusEvent(FocusEvent fe) {
    super.processFocusEvent(fe);

    if (PropUtils.isLoggable(BaseTable.class)) {
        PropUtils.log(BaseTable.class, "processFocusEvent - "); //NOI18N
        PropUtils.log(BaseTable.class, fe);
    }

    if (!isAncestorOf(fe.getOppositeComponent()) || (fe.getOppositeComponent() == null)) {
        if (isEditing() && (fe.getID() == fe.FOCUS_LOST)) {
            if (PropUtils.isLoggable(BaseTable.class)) {
                PropUtils.log(
                    BaseTable.class, "ProcessFocusEvent got focus lost to unknown component, removing editor"
                ); //NOI18N
            }

            focusLostCancel();
        }
    }

    if (!inEditorRemoveRequest() && !inEditRequest()) { //XXX inEditRequest probably shouldn't be here

        if ((fe.getOppositeComponent() == null) && (fe.getID() == fe.FOCUS_LOST)) {
            //ignore the strange focus to null stuff NetBeans does
            return;
        }

        paintSelectionRow();
    } else {
        paintSelectionRow();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:BaseTable.java

示例6: forwardFocusLost

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
void forwardFocusLost( FocusEvent e) {
    isFocused = false;
    FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
            e.getOppositeComponent(), e.getCause());
    super.processFocusEvent(fe);

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

示例7: focusLost

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
@Override
public void focusLost(FocusEvent e) {
    Component c = e.getOppositeComponent();
    if (c != searchCombo) {
        removeSearchField();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:ETable.java

示例8: focusLost

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
@Override
public void focusLost(FocusEvent e) {
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("Focus Lost from "+e.getComponent());
        logger.fine("  opposite component is: "+e.getOppositeComponent());
    }
    e.getComponent().removeFocusListener(this);
    synchronized (EditorContextDispatcher.this) {
        if (e.getOppositeComponent() == currentTextComponent.get()) {
            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Opposite is current. No update.");
            }
            return ;
        }
    }
    update(true);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:EditorContextDispatcher.java

示例9: forwardFocusGained

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
void forwardFocusGained( FocusEvent e) {
    isFocused = true;
    FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
            e.getOppositeComponent(), e.getCause());
    super.processFocusEvent(fe);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:XTextFieldPeer.java

示例10: tfClassToTestFocusLost

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
/**
 */
private void tfClassToTestFocusLost(FocusEvent e) {
    final Component allowFocusGain = focusGainAllowedFor;
    focusGainAllowedFor = null;
    
    if (multipleSourceRoots
            && interactionRestrictionsActive
            && !interactionRestrictionsSuspended) {

        final Component opposite = e.getOppositeComponent();

        if ((allowFocusGain != null) && (opposite == allowFocusGain)) {
            return;
        }
        if (opposite == btnBrowse) {
            return;
        }
        if ((opposite instanceof JLabel)
                && (((JLabel) opposite).getLabelFor() == tfClassToTest)) {
            /*
             * When a JLabel's mnemonic key is pressed, the JLabel gains focus
             * until the key is released again. That's why we must ignore such
             * focus transfers.
             */
            return;
        }
        
        if (!maybeDisplaySourceGroupChooser()) {
            
            /* send the request back to the Test to Class textfield: */
            tfClassToTest.requestFocus();
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:SimpleTestStepLocation.java

示例11: btnBrowseFocusLost

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
/**
 */
private void btnBrowseFocusLost(FocusEvent e) {
    final Component allowFocusGain = focusGainAllowedFor;
    focusGainAllowedFor = null;
    
    if (multipleSourceRoots
            && interactionRestrictionsActive
            && !interactionRestrictionsSuspended) {

        final Component opposite = e.getOppositeComponent();

        if ((allowFocusGain != null) && (opposite == allowFocusGain)) {
            return;
        }
        if (opposite == tfClassToTest) {
            return;
        }
        if ((opposite instanceof JLabel)
                && (((JLabel) opposite).getLabelFor() == tfClassToTest)) {
            /*
             * When a JLabel's mnemonic key is pressed, the JLabel gains focus
             * until the key is released again. That's why we must ignore such
             * focus transfers.
             */
            return;
        }

        if (!maybeDisplaySourceGroupChooser()) {
            
            /* send the request back to the Browse... button: */
            btnBrowse.requestFocus();
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:SimpleTestStepLocation.java

示例12: focusLost

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
@Override
public void focusLost(FocusEvent e) {
	if (e.getOppositeComponent() != arrowButton && e.getOppositeComponent() != getPopupMenu()) {
		hovered = false;
		setBorderPainted(false);
		arrowButton.setBorderPainted(false);
		setForeground(NORMAL_TEXTCOLOR);
		repaint();
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:11,代碼來源:FancyDropDownButton.java

示例13: focusLost

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
@Override
public void focusLost(FocusEvent e) {
	// Only dispose of tip if it wasn't the TipWindow that was clicked
	// "c" can be null, at least on OS X, so we must check that before
	// calling SwingUtilities.getWindowAncestor() to guard against an
	// NPE.
	Component c = e.getOppositeComponent();
	boolean tipClicked = (c instanceof TipWindow) ||
		(c!=null &&
			SwingUtilities.getWindowAncestor(c) instanceof TipWindow);
	if (!tipClicked) {
		possiblyDisposeOfTipWindow();
	}
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:15,代碼來源:FocusableTip.java

示例14: restoreFocus

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
private void restoreFocus(FocusEvent fe, Window newFocusedWindow) {
    Component realOppositeComponent = this.realOppositeComponentWR.get();
    Component vetoedComponent = fe.getComponent();

    if (newFocusedWindow != null && restoreFocus(newFocusedWindow,
                                                 vetoedComponent, false))
    {
    } else if (realOppositeComponent != null &&
               doRestoreFocus(realOppositeComponent, vetoedComponent, false)) {
    } else if (fe.getOppositeComponent() != null &&
               doRestoreFocus(fe.getOppositeComponent(), vetoedComponent, false)) {
    } else {
        clearGlobalFocusOwnerPriv();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:DefaultKeyboardFocusManager.java

示例15: retargetFocusEvent

import java.awt.event.FocusEvent; //導入方法依賴的package包/類
static AWTEvent retargetFocusEvent(AWTEvent event) {
    if (clearingCurrentLightweightRequests) {
        return event;
    }

    KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        if (event instanceof FocusEvent || event instanceof WindowEvent) {
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
        if (focusLog.isLoggable(PlatformLogger.Level.FINER) && event instanceof KeyEvent) {
            focusLog.finer("    focus owner is {0}",
                           String.valueOf(manager.getGlobalFocusOwner()));
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
    }

    synchronized(heavyweightRequests) {
        /*
         * This code handles FOCUS_LOST event which is generated by
         * DefaultKeyboardFocusManager for FOCUS_GAINED.
         *
         * This code based on knowledge of DefaultKeyboardFocusManager's
         * implementation and might be not applicable for another
         * KeyboardFocusManager.
         *
         * Fix for 4472032
         */
        if (newFocusOwner != null &&
            event.getID() == FocusEvent.FOCUS_LOST)
        {
            FocusEvent fe = (FocusEvent)event;

            if (manager.getGlobalFocusOwner() == fe.getComponent() &&
                fe.getOppositeComponent() == newFocusOwner)
            {
                newFocusOwner = null;
                return event;
            }
        }
    }

    processCurrentLightweightRequests();

    switch (event.getID()) {
        case FocusEvent.FOCUS_GAINED: {
            event = retargetFocusGained((FocusEvent)event);
            break;
        }
        case FocusEvent.FOCUS_LOST: {
            event = retargetFocusLost((FocusEvent)event);
            break;
        }
        default:
            /* do nothing */
    }
    return event;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:59,代碼來源:KeyboardFocusManager.java


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