Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

No Adapter for DocumentListener?

 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • 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.
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!