This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need some with a program that won't compile.

 
Steve Vittoria
Ranch Hand
Posts: 35
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • 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: 35
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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: 35
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thank you so much Ernest!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic