58 |
import java.awt.event.MouseWheelListener; |
import java.awt.event.MouseWheelListener; |
59 |
import java.awt.event.MouseWheelEvent; |
import java.awt.event.MouseWheelEvent; |
60 |
import java.awt.event.PaintEvent; |
import java.awt.event.PaintEvent; |
61 |
|
import java.awt.event.WindowEvent; |
62 |
import java.awt.im.InputContext; |
import java.awt.im.InputContext; |
63 |
import java.awt.im.InputMethodRequests; |
import java.awt.im.InputMethodRequests; |
64 |
import java.awt.image.BufferStrategy; |
import java.awt.image.BufferStrategy; |
3433 |
*/ |
*/ |
3434 |
public boolean isFocusTraversable() |
public boolean isFocusTraversable() |
3435 |
{ |
{ |
3436 |
return enabled && visible && (peer == null || peer.isFocusTraversable()); |
return enabled && visible && (peer == null || isLightweight() || peer.isFocusTraversable()); |
3437 |
} |
} |
3438 |
|
|
3439 |
/** |
/** |
3448 |
} |
} |
3449 |
|
|
3450 |
/** |
/** |
3451 |
* Specify whether this component can receive focus. |
* Specify whether this component can receive focus. This method also |
3452 |
|
* sets the {@link #isFocusTraversableOverridden} field to 1, which |
3453 |
|
* appears to be the undocumented way {@link |
3454 |
|
* DefaultFocusTraversalPolicy#accept()} determines whether to respect |
3455 |
|
* the {@link #isFocusable()} method of the component. |
3456 |
* |
* |
3457 |
* @param focusable the new focusable status |
* @param focusable the new focusable status |
3458 |
* @since 1.4 |
* @since 1.4 |
3461 |
{ |
{ |
3462 |
firePropertyChange("focusable", this.focusable, focusable); |
firePropertyChange("focusable", this.focusable, focusable); |
3463 |
this.focusable = focusable; |
this.focusable = focusable; |
3464 |
|
this.isFocusTraversableOverridden = 1; |
3465 |
} |
} |
3466 |
|
|
3467 |
/** |
/** |
3720 |
Window toplevel = (Window) parent; |
Window toplevel = (Window) parent; |
3721 |
if (toplevel.isFocusableWindow ()) |
if (toplevel.isFocusableWindow ()) |
3722 |
{ |
{ |
3723 |
if (peer != null) |
if (peer != null && !isLightweight()) |
3724 |
// This call will cause a FOCUS_GAINED event to be |
// This call will cause a FOCUS_GAINED event to be |
3725 |
// posted to the system event queue if the native |
// posted to the system event queue if the native |
3726 |
// windowing system grants the focus request. |
// windowing system grants the focus request. |
3806 |
Window toplevel = (Window) parent; |
Window toplevel = (Window) parent; |
3807 |
if (toplevel.isFocusableWindow ()) |
if (toplevel.isFocusableWindow ()) |
3808 |
{ |
{ |
3809 |
if (peer != null) |
if (peer != null && !isLightweight()) |
3810 |
// This call will cause a FOCUS_GAINED event to be |
// This call will cause a FOCUS_GAINED event to be |
3811 |
// posted to the system event queue if the native |
// posted to the system event queue if the native |
3812 |
// windowing system grants the focus request. |
// windowing system grants the focus request. |
3927 |
if (focusedWindow == toplevel) |
if (focusedWindow == toplevel) |
3928 |
{ |
{ |
3929 |
if (peer != null |
if (peer != null |
3930 |
|
&& !isLightweight() |
3931 |
&& !(this instanceof Window)) |
&& !(this instanceof Window)) |
3932 |
// This call will cause a FOCUS_GAINED event to be |
// This call will cause a FOCUS_GAINED event to be |
3933 |
// posted to the system event queue if the native |
// posted to the system event queue if the native |
4697 |
* |
* |
4698 |
* @param e the event to dispatch |
* @param e the event to dispatch |
4699 |
*/ |
*/ |
4700 |
|
|
4701 |
void dispatchEventImpl (AWTEvent e) |
void dispatchEventImpl (AWTEvent e) |
4702 |
{ |
{ |
4703 |
Event oldEvent = translateEvent (e); |
Event oldEvent = translateEvent (e); |
4706 |
postEvent (oldEvent); |
postEvent (oldEvent); |
4707 |
|
|
4708 |
if (eventTypeEnabled (e.id)) |
if (eventTypeEnabled (e.id)) |
4709 |
|
{ |
4710 |
|
// the trick we use to communicate between dispatch and redispatch |
4711 |
|
// is to have KeyboardFocusManager.redispatch synchronize on the |
4712 |
|
// object itself. we then do not redispatch to KeyboardFocusManager |
4713 |
|
// if we are already holding the lock. |
4714 |
|
if (! Thread.holdsLock(e)) |
4715 |
|
{ |
4716 |
|
switch (e.id) |
4717 |
|
{ |
4718 |
|
case WindowEvent.WINDOW_GAINED_FOCUS: |
4719 |
|
case WindowEvent.WINDOW_LOST_FOCUS: |
4720 |
|
case KeyEvent.KEY_PRESSED: |
4721 |
|
case KeyEvent.KEY_RELEASED: |
4722 |
|
case KeyEvent.KEY_TYPED: |
4723 |
|
case FocusEvent.FOCUS_GAINED: |
4724 |
|
case FocusEvent.FOCUS_LOST: |
4725 |
|
if (KeyboardFocusManager |
4726 |
|
.getCurrentKeyboardFocusManager() |
4727 |
|
.dispatchEvent(e)) |
4728 |
|
return; |
4729 |
|
} |
4730 |
|
} |
4731 |
processEvent (e); |
processEvent (e); |
4732 |
} |
} |
4733 |
|
} |
4734 |
|
|
4735 |
/** |
/** |
4736 |
* Tells whether or not an event type is enabled. |
* Tells whether or not an event type is enabled. |