• 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

event handling error .. need help

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


/*

C:\>javac Mouse1.java
Mouse1.java:12: Mouse1 is not abstract and does not override abstract method mou
seReleased(java.awt.event.MouseEvent) in java.awt.event.MouseListener
public class Mouse1 extends Applet implements MouseListener, MouseMotionListener
^
1 error

*/
[/code]
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Abhay,
Whenever you implement an interface,make sure you satisfy the contract specified by the interface.
The error message clearly states that
mouseReleased(java.awt.event.MouseEvent) method declared in the interface is not implemented in your class.

You can just provide a dummy implementation if you do not wish to handle the mousereleased event.
public void mouseReleased(java.awt.event.MouseEvent e)
{
`
}

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



You can just provide a dummy implementation if you do not wish to handle the mousereleased event.
public void mouseReleased(java.awt.event.MouseEvent e)
{
`
}

Thanks
Yogi



thanks yogi ,
it works after one more .....mousePressed event , so we can say that it was necessary to put that dummy code because we implemented related interfaces .. right ?? or there is another reason behind it ??
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If a class implements an interface it must implement all methods of that interface. In those cases you don't want to, you must provide skeleton implementations - empty bodies where void is returned, and returning some constant where a return value is required.
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic