aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Platform dependent FocusListener behavior... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Platform dependent FocusListener behavior..." Watch "Platform dependent FocusListener behavior..." New topic
Author

Platform dependent FocusListener behavior...

Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

A strange problem cropped up here at work... it has been solved, so no-one should feel pressured to fix it... I was just wondering if anyone else had experienced it, or knew why it was happening, or to help someone out with the solution if it happens to them.
A friend of mine here at work was working on validating dates in JTextFields ( which threads here on JavaRanch helped out mightily on! )... He was using a FocusListener to listen for FocusLost to run the validation. He started developing his code on a Windows NT machine and it was working fine, he then move it to a Solaris machine. Everything worked fine, except when arrow keys are pressed in the JTextField, a FocusLost event is thrown and the data in the text field is re-validated, effectively forcing the caret to the end of the text any time an arrow key is pressed anywhere in the program. I tried to figure out what event was being thrown, so I printed out the event being thrown. I noticed that a temporary FocusLost was being thrown when the arrows were pressed, so we added a test to ignore any FocusEvent when isTemporary() returns true. It seemed to work great, so we went back and tested it on Windows... it seems that Windows does not throw a temporary FocusLost event when arrows are pressed in JTextFields, but Solaris does. I would expect this kind of thing from the AWT, but I thought that Swing was supposed to remove platform dependent behavior like this from GUI programming! The only reason that I can come up with is that FocusListener is in the AWT (java.awt.event), so some old platform dependent code may still be in there...
-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I got another one for you.

We were doing development work and our target platform was a device called "Clio". When our program worked fine on our NT development boxes, and appeared to not work at all on the Clio, we eventually discovered that Clio would throw the mousePressed and mouseReleased, but would fail to fire the mouseClicked.

Guess what all of our code depended on?

Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Guys,
All low level events are still AWT. Swing only added new ones and changed the displays of UI objects.
Manfred.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Platform dependent FocusListener behavior...