• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

problem of MouseListener interface

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

I'm developing a dialog for that I've written a class.
In that class I've to implement an interface MouseListener but dont want to implement all method.
but I have already extended one class JDialog.

Is there any way to not to implement all method

Posts: 22791
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only way to not have to implement all methods is to extend MouseAdapter or MouseInputAdapter. That will not be possible for you since you already extend JDialog, so you have three options:

1) implement all methods.
2a) don't let your JDialog implement MouseListener, but use an inner class (use our search or Google if you are not familiar with it) instead.
2b) like 2a but use an anonymous inner class (again, the search and Google are your friends) instead of a regular one.

I would definitely check out how 2a and 2b work, because having your GUI class be its own listener is not a good practice. Not only will you always have to implement all listener methods, but it also allows other classes to use it as a listener for their components. That's not something you want.
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic