• 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

No Adapter for DocumentListener?

 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there,
I have a JTextField that contains a file name. The contents of that field may change as a result of typing in it or as a result of browsing and selecting a file.
Now, I need a listener for this text field, and the KeyAdapter will work if something is typed, but not when the text is set from browing.
So that means that I need to use DocumentListener, but I dont want to override all three methods of it. How come there is no adapter for it?
Thanks,
Eugene.
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I worked with DocumentListener and I find it better than KeyListener.
The DocumentAdapter would do nothing else than provide a blank implementation (no code) for every method. Either you make your own DocumentAdapter or you extend DocumentListener and provide empty implementations for those methods you don't need to listen to.
Chantal
reply
    Bookmark Topic Watch Topic
  • New Topic