Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange problem with focus owner



All,

This problem is platform independent, but I've come to rely on this group as a source of valuable java knowledge regardless of platform, and I'
m hoping someone might have a suggestion for me.

What's happening is this. I have a JFrame that is being "popped out" after a user picks an option from a modal menu panel (somewhat like a right click, but slightly different). There is an EOTextField (subclass of JTextField) at the top of the window, and I want this field to have focus when the window first appears. I had been using some code which seemed to be working fine, but we've recently discovered a vexing bug and while debugging the problem, I noticed something very odd.

What I found is this, when I commented out the code I had written to set this field as the focus owner, when the panel appears, there is no visual sign that anything has focus (no blinking cursor or highlighted button or the like), but when I type, the characters appear at the end of the field that I wanted selected. I put in a log statement after the window (JFrame) is set to visible to see who the focus owner is (myFrame.getFocusOwner), and the result is always null until I explicitly click in this field.

In reading over the Sun forum issues and looking at the beginning of this document:

http://java.sun.com/j2se/1.4/docs/api/java/awt/doc-files/FocusSpec.html

It looks as if I am not alone in experiencing focus problems. My only hope is that someone might have experienced this type of problem before and might have some suggestions on how to work around it. The real question I have is how does it happen that I am in this state where there is no focus owner and no cursor in a text field, but when I type, characters are going into that field. Maybe if I can understand that issue, I can figure out how to fix this.

Thanks,
Paul
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.