• 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

[newbie] The type MouseComponent must implement the inherited abstract method MouseMotionListener...

 
Ranch Hand
Posts: 664
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is wot I see...



Output:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems:
The type MouseComponent must implement the inherited abstract method MouseMotionListener.mouseMoved(MouseEvent)
The type MouseComponent must implement the inherited abstract method MouseMotionListener.mouseDragged(MouseEvent)
Rectangel2D cannot be resolved to a type
Rectangel2D cannot be resolved to a type
Cannot instantiate the type MouseMotionListener
This method must return a result of type Rectangle2D
The method add(Component) in the type Container is not applicable for the arguments (Point)

at MouseComponent.<init>(MouseComponent.java:14)
at MouseFrame.<init>(MouseFrame.java:10)
at MouseTest$1.run(MouseTest.java:14)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

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

to this
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You code does not compile because of the following reasons


The type MouseComponent must implement the inherited abstract method MouseMotionListener.mouseMoved(MouseEvent)
The type MouseComponent must implement the inherited abstract method MouseMotionListener.mouseDragged(MouseEvent)
Rectangel2D cannot be resolved to a type
Rectangel2D cannot be resolved to a type
Cannot instantiate the type MouseMotionListener
This method must return a result of type Rectangle2D
The method add(Component) in the type Container is not applicable for the arguments (Point)



Use your IDE's quick hint or resolution techniques to fix the problem. Ctrl + 1 in eclipse. Click on the bulb on the sidebar in netbeans
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are saying your object is a MouseMotionListener, then you are telling the compiler it has the 5 methods of that interface. Details here. So you have to implement 5 methods, even if some of them are empty, and you have to ensure that the method names are spelt correctly, same return type, etc. Remember they are all implicitly "public".
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic