本文整理汇总了Java中java.awt.event.FocusEvent.FOCUS_LOST属性的典型用法代码示例。如果您正苦于以下问题:Java FocusEvent.FOCUS_LOST属性的具体用法?Java FocusEvent.FOCUS_LOST怎么用?Java FocusEvent.FOCUS_LOST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.event.FocusEvent
的用法示例。
在下文中一共展示了FocusEvent.FOCUS_LOST属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processFocusEvent
@Override
protected void processFocusEvent(FocusEvent fe) {
super.processFocusEvent(fe);
//Remove the editor here if the new focus owner is not
//known to the table & the focus event is not temporary
if ((fe.getID() == FocusEvent.FOCUS_LOST) && !fe.isTemporary() && !inRemoveRequest && !inEditRequest) {
boolean stopEditing = ((fe.getOppositeComponent() != getParent()) &&
!isKnownComponent(fe.getOppositeComponent()) && (fe.getOppositeComponent() != null));
if (stopEditing) {
removeEditor();
}
}
//The UI will only repaint the lead selection, but we need to
//paint all selected rows for the color to change when focus
//is lost/gained
if (!inRemoveRequest && !inEditRequest) {
repaintSelection(fe.getID() == FocusEvent.FOCUS_GAINED);
}
}
示例2: retargetUnexpectedFocusEvent
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);
}
}
示例3: retargetUnexpectedFocusEvent
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);
}
}
示例4: processFocusEvent
@Override
protected void processFocusEvent(FocusEvent fe) {
super.processFocusEvent(fe);
if (fe.getID() == FocusEvent.FOCUS_LOST) {
stopTimer();
}
}
示例5: clearGlobalFocusOwner
@Override
public void clearGlobalFocusOwner(Window activeWindow) {
if (activeWindow != null) {
Component focusOwner = activeWindow.getFocusOwner();
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
focusLog.fine("Clearing global focus owner " + focusOwner);
}
if (focusOwner != null) {
FocusEvent fl = new CausedFocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
SunToolkit.postPriorityEvent(fl);
}
}
}
示例6: clearGlobalFocusOwner
@Override
public void clearGlobalFocusOwner(Window activeWindow) {
if (activeWindow != null) {
Component focusOwner = activeWindow.getFocusOwner();
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
focusLog.fine("Clearing global focus owner " + focusOwner);
}
if (focusOwner != null) {
FocusEvent fl = new FocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
SunToolkit.postPriorityEvent(fl);
}
}
}
示例7: handleJavaFocusEvent
/**
* Restoring native behavior. We should sets the selection range to zero,
* when component lost its focus.
*
* @param e the focus event
*/
@Override
void handleJavaFocusEvent(final FocusEvent e) {
if (e.getID() == FocusEvent.FOCUS_LOST) {
// In order to de-select the selection
setCaretPosition(0);
}
super.handleJavaFocusEvent(e);
}
示例8: retargetFocusEvent
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;
}
示例9: handleEvent
@Override
@SuppressWarnings("fallthrough")
public void handleEvent(AWTEvent e) {
int id = e.getID();
if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() &&
((Component)target).isEnabled())
{
if (e instanceof MouseEvent && !(e instanceof MouseWheelEvent)) {
handleJavaMouseEvent((MouseEvent) e);
} else if (e instanceof KeyEvent) {
if (handleJavaKeyEvent((KeyEvent)e)) {
return;
}
}
}
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,shouldClearRectBeforePaint());
}
return;
case FocusEvent.FOCUS_LOST:
case FocusEvent.FOCUS_GAINED:
handleJavaFocusEvent((FocusEvent)e);
default:
break;
}
// Call the native code
nativeHandleEvent(e);
}
示例10: deliverFocus
@SuppressWarnings("deprecation")
public static boolean deliverFocus(Component lightweightChild,
Component target,
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
CausedFocusEvent.Cause cause,
Component currentFocusOwner) // provided by the descendant peers
{
if (lightweightChild == null) {
lightweightChild = target;
}
Component currentOwner = currentFocusOwner;
if (currentOwner != null && currentOwner.getPeer() == null) {
currentOwner = null;
}
if (currentOwner != null) {
FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST,
false, lightweightChild, cause);
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
focusLog.finer("Posting focus event: " + fl);
}
SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl);
}
FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
false, currentOwner, cause);
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
focusLog.finer("Posting focus event: " + fg);
}
SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg);
return true;
}
示例11: deliverFocus
@SuppressWarnings("deprecation")
public static boolean deliverFocus(Component lightweightChild,
Component target,
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
FocusEvent.Cause cause,
Component currentFocusOwner) // provided by the descendant peers
{
if (lightweightChild == null) {
lightweightChild = target;
}
Component currentOwner = currentFocusOwner;
if (currentOwner != null && !currentOwner.isDisplayable()) {
currentOwner = null;
}
if (currentOwner != null) {
FocusEvent fl = new FocusEvent(currentOwner, FocusEvent.FOCUS_LOST,
false, lightweightChild, cause);
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
focusLog.finer("Posting focus event: " + fl);
}
SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl);
}
FocusEvent fg = new FocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
false, currentOwner, cause);
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
focusLog.finer("Posting focus event: " + fg);
}
SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg);
return true;
}
示例12: 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;
}
}
示例13: dispatchEvent
/**
* @see java.awt.im.InputContext#dispatchEvent
*/
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {
if (event instanceof InputMethodEvent) {
return;
}
// Ignore focus events that relate to the InputMethodWindow of this context.
// This is a workaround. Should be removed after 4452384 is fixed.
if (event instanceof FocusEvent) {
Component opposite = ((FocusEvent)event).getOppositeComponent();
if ((opposite != null) &&
(getComponentWindow(opposite) instanceof InputMethodWindow) &&
(opposite.getInputContext() == this)) {
return;
}
}
InputMethod inputMethod = getInputMethod();
int id = event.getID();
switch (id) {
case FocusEvent.FOCUS_GAINED:
focusGained((Component) event.getSource());
break;
case FocusEvent.FOCUS_LOST:
focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
break;
case KeyEvent.KEY_PRESSED:
if (checkInputMethodSelectionKey((KeyEvent)event)) {
// pop up the input method selection menu
InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
break;
}
// fall through
default:
if ((inputMethod != null) && (event instanceof InputEvent)) {
inputMethod.dispatchEvent(event);
}
}
}
示例14: 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;
}
}