本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例7: focusLost
import java.awt.event.FocusEvent; //导入方法依赖的package包/类
@Override
public void focusLost(FocusEvent e) {
Component c = e.getOppositeComponent();
if (c != searchCombo) {
removeSearchField();
}
}
示例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);
}
示例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);
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}