Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

problem with focus listener  RSS feed

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I registered focus lisener on JTextField. The listener getting called 2 times during 'TAB' out.
Why does Focus Lost event gets called twice for all the JTextFields ??

I want to do some valiadtion on 'TAB' out of JTextField?
Is there any alternative for this?

Please advise ..

Thanks in advance
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try printing all the focus listeners, see if somehow the same listener gets added twice.
i used the same approach to detect tab out, it only gets called once
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by jyothi ve:
I registered focus lisener on JTextField. The listener getting called 2 times during 'TAB' out.
Why does Focus Lost event gets called twice for all the JTextFields ??



Make sure the listener is added only once in the constructor... If ur code contains some other manipulation on the listeners added to the JTextField, I do suggest you to have a look carefully at those code...

Or you might want to provide us with a part of your code so that we can help you more...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!