• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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
Hi,

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

thanks
 
Sheriff
Posts: 22849
132
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic