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

problem of MouseListener interface

 
swapnel surade
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • 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
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!