Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Unwanted Focus Event

Reply
Thread Tools

Unwanted Focus Event

 
 
Bill Dennis
Guest
Posts: n/a
 
      06-03-2004
I've got a glitch in my code that I just can't track down. When
editing a table cell, if I then click on (or even cursor to) another
table cell, a JTextField on the screen (not in the table), momentarily
gets focus, then focus jumps back to the table. I've found that when
I press the mouse key, focus jumps to the field, then when I release
the mouse key, focus goes back to the table. I've tried overriding
the requestFocus() and grabFocus() methods of the JTextField, and even
the focusNextComponent() method of the FocusManager, but none of them
is being called. Yet the focusLost() and focusGained() methods of the
JTextField's FocusListener are being invoked. I can't figure out
where the FocusEvent is coming from, thought I'm thinking it must be
somewhere in my code, though I've put in some println's everywhere
that I create a FocusEvent, and none of them is being called either.
How can I find out what is causing the focusLost() and focusGained()
to be called (i.e., who is adding the FocusEvents to the EDT)?
Thanks.

Bill Dennis
 
Reply With Quote
 
 
 
 
Kleopatra
Guest
Posts: n/a
 
      06-04-2004


Bill Dennis wrote:
>
> I've got a glitch in my code that I just can't track down. When
> editing a table cell, if I then click on (or even cursor to) another
> table cell, a JTextField on the screen (not in the table), momentarily
> gets focus, then focus jumps back to the table. I've found that when
> I press the mouse key, focus jumps to the field, then when I release
> the mouse key, focus goes back to the table. I've tried overriding
> the requestFocus() and grabFocus() methods of the JTextField, and even
> the focusNextComponent() method of the FocusManager, but none of them
> is being called. Yet the focusLost() and focusGained() methods of the
> JTextField's FocusListener are being invoked. I can't figure out
> where the FocusEvent is coming from, thought I'm thinking it must be
> somewhere in my code, though I've put in some println's everywhere
> that I create a FocusEvent, and none of them is being called either.
> How can I find out what is causing the focusLost() and focusGained()
> to be called (i.e., who is adding the FocusEvents to the EDT)?


Sounds weird - but not very much so: there are loads of focus/editing
related glitches in JTable (never ran into this particular one, though).
Could you provide a small (!) compilable runnable example that
demonstrates the problem?

Alternatively you can track all focus events by registering a
PropertyChangeListener with the KeyboardFocusManager on the
(permanent)focusOwner property - I suspect the table to do a
requestFocus when editing is terminated, just a guess, though.

Greetings
Jeanette

PS: a better place for Swing related questions is comp.lang.java.gui
because it's focused on gui issues. You might consider asking there next
time.

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      06-04-2004
On Fri, 04 Jun 2004 09:48:34 +0200, Kleopatra wrote:

> Could you provide a small (!) compilable runnable example that
> demonstrates the problem?


Check here for tips on preparing that example..
<http://www.physci.org/codes/sscce.jsp>

[ ..which I would strongly suggest, since your
post has apparently grabbed the attention of
one of the Swing Guru's. ]

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
emulating window.focus in Body onload() event and setting focus to a control on same page Jason ASP .Net 4 05-07-2007 05:54 PM
this.window.focus() vs. window.focus() vs. this.focus() Roger Javascript 3 03-08-2007 08:53 PM
Pan Focus vs Auto Focus JethroUK© Digital Photography 2 08-11-2004 06:26 PM
Previous(Unwanted) event handled when page refreshed by key F5 sanjay patil via .NET 247 ASP .Net 0 04-27-2004 04:02 AM
any manual focus cameras easy to focus? Catherine Jo Morgan Digital Photography 6 11-05-2003 06:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57