• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Focus issues among JTextField and Dialogs

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, there:

After upgrading jdk from 1.3 to 1.4, we met following focus issues:
Ex. We have 2 text fields, textTest1 and textTest3, and one dialog. textTest1 registered to a key listener so that when 'Esc' key pressed, the dialog popped up, after pressed 'ok' key in that dialog, we want to transfer focus to another text field textTest3 (textTest3.requestFocus() is called inside keyPressed() method). After I added a focusListener for textTest3, I noticed the difference between jdk1.3 and 1.4:
jdk1.3: only focusGained() is called once.
jdk1.4: a. focusGained() is called (gained focus from "OK" button of dialog); b. focusLost() is called( focus lost to textTest1); c. focusGained() is called again (gained focus from textTest1).
My problem is that those extra focusGained() and focusLost() called in jdk1.4 brings me some issues in my application. Is there any straightforward way to ignore these 2 extra function calling? I can find 2 options:
a. added focus listener for textTest1, and remove textTest3.requestFocus() from keyListener to that focusListener, however it doesn't work for my application (too many components should add that focusListener);
b. added a flag, and set that flag before textTest3.requestFocus is called, and ignore those 2 extra callings.
So, again is there any other option besides above 2 can solve my issue? I included an example code below:


Highly appreciated if any comments, suggestions on that issue, thanks a lot in advance.
David
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic