This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Platform dependent FocusListener behavior...

 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic