• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Need some with a program that won't compile.

 
Ranch Hand
Posts: 37
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone! Hope I'm posting this in the right forum.

I'm trying to work with an example code of a Slide Puzzle game ( found here), and I get the following error when I try and compile it...

C:\My Projects\Slider\src\slider\SliderGUI.java:34: slider.SliderGUI.GraphicsPanel is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
class GraphicsPanel extends JPanel implements MouseListener {
Note: C:\My Projects\Slider\src\slider\Slider.java uses or overrides a deprecated API.
Note: Recompile with -Xlint eprecation for details.

Here is the code...



I'm new to Java so I'm having a whale of a time trying to figure out what the compiler is trying to tell me. Any clues?

Thanks!
Steve
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first error about not being abstract is trying to tell you that since your class SliderGUI.GraphicsPanel declares that it implements MouseListener, it must implement all the methods declared in the MouseListener interface; you've only implemented one. mousePressed(). The error message names another one, mouseExited(), but there are four more, I believe. You'll have to look it up in the Javadoc.

The second warning message about a deprecated API, you can get more specifics if you compile with the -Xlint switch to javac. A "deprecated API" is a class or method in the library that you shouldn't use anymore because a better alternative exists; it's still there only for backwards compatibility. Use -Xlint to find out what deprecated API you're using, and then go look at the Javadoc for that class or method -- it will tell you what to use instead.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not having that problem. Are you copying/pasting the code? Are you putting the three classes each in their own file?
 
Steve Vittoria
Ranch Hand
Posts: 37
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies guys.

Ok, so added -Xlint option and I don't get that much more information. Here's what I get with -Xlint enable...

Created dir: C:\My Projects\Slider\build\classes
Compiling 3 source files to C:\My Projects\Slider\build\classes
C:\My Projects\Slider\src\slider\SliderGUI.java:34: slider.SliderGUI.GraphicsPanel is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
class GraphicsPanel extends JPanel implements MouseListener {
C:\My Projects\Slider\src\slider\SliderGUI.java:34: warning: [serial] serializable class slider.SliderGUI.GraphicsPanel has no definition of serialVersionUID
class GraphicsPanel extends JPanel implements MouseListener {
C:\My Projects\Slider\src\slider\SliderGUI.java:8: warning: [serial] serializable class slider.SliderGUI has no definition of serialVersionUID
class SliderGUI extends JPanel {
1 error
2 warnings
BUILD FAILED (total time: 0 seconds)

I had a look at the Javadoc and I'm still confused as to what I have to do. According to the Javadoc, "the class that is interested in processing a mouse event either implements this interface (and all the methods it contains) or extends the abstract MouseAdapter class (overriding only the methods of interest)."

So I tried doing the following, but still it didn't work...


I'm sure this is a quite simple problem, but I can't see the solution. Any tips?
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's real close but...

public void mouseExtited(MouseEvent e) {

compilers are real picky about spelling!
 
Steve Vittoria
Ranch Hand
Posts: 37
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Thank you so much Ernest!
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic