No direct help (sorry) - but there is a method
SwingUtilities.findFocusOwner() - I don't recall the correct name. It
has been very helpful for me while debugging focus problems. After you
know which component has the focus you can look into the source of that
component to find out what's happening (JTable f.i. has an "incomplete"
editing mode in which it receives all the keystrokes and routes the
action associated with them to the textfield that it thinks has the
focus - the behaviour then is similar to what you see).

Greetings
Jeanette


Lyric schrieb:
> 
> I am experiencing problems with unexpected focus loss from my
> components.
> 
> My interface contains a JList with a custom MouseListener. The
> JList contains items that themselves contain JTextFields.
> mouseClicked(), after some logic, may call requestFocus() on one
> of those JTextFields.
> 
> The requestFocus() is successful as verified by a successful
> hasFocus() call immediately after. It has also been verified by a
> FocusListener listening for focus changes on the JTextField in
> question - the JTextField definitely receives the keyboard focus.
> 
> However, immediately after listeners are notified and the
> hasFocus() completes, the component LOSES focus again
> (according to the FocusListener).
> 
> Here's the puzzling thing: all the focus listening tells me the
> JTextField has lost focus. There is no blinking cursor in the
> JTextField that would indicate focus. (I've played with all the caret
> position and visibility functions too - they don't help.) BUT, the
> JTextField still receives keystrokes! My DocumentListener is
> notified with correct text changes and it's fireContentsChanged()'ing
> just fine - which means that changes to the text in the JTextField
> repaint and show up in the GUI just fine. But there is NO blinking
> cursor and Swing insists the component does NOT have focus!
> 
> I am completely baffled. Can anyone shed some light on this?
> 
> - John Stoneham
> _______________________________________________
> Advanced-swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/advanced-swing


_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to