Mailing Lists: Apple Mailing Lists

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

Re: Strange problem with focus owner



All,

Interestingly, there is an OS X platform dependent twist on this:

OS X 10.1.5
3-toscani% java -version ~
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-root-020402-19:35)
Java HotSpot(TM) Client VM (build 1.3.1, mixed mode)

On windows, running 1.3.1_03, if I don't programmatically request focus for my field, it gets focus by default somehow (I think java is supposed to do this automatically). On os x however, I end up in the weird state that I described below where I can type into the field, but the cursor does not appear and the JFrame's focus owner is null. The problem is that, once I am in this state, no matter what I seem to do programmatically on either platform, I can't get the focus problem to correct itself. The user has to manually tab out of the field or click somewhere else and then shift-tab or click back into the field and then focus is properly restored.

Regards,
Paul

On Tuesday, August 20, 2002, at 03:09 PM, Paul R. Summermatter wrote:

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.
_______________________________________________
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.

References: 
 >Strange problem with focus owner (From: "Paul R. Summermatter" <email@hidden>)



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.