wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Need some with a program that won't compile. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need some with a program that won Watch "Need some with a program that won New topic
Author

Need some with a program that won't compile.

Steve Vittoria
Ranch Hand

Joined: Jan 12, 2005
Posts: 33

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

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
I'm not having that problem. Are you copying/pasting the code? Are you putting the three classes each in their own file?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Steve Vittoria
Ranch Hand

Joined: Jan 12, 2005
Posts: 33

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

Joined: Jul 08, 2003
Posts: 24183
    
  34

That's real close but...

public void mouseExtited(MouseEvent e) {

compilers are real picky about spelling!
Steve Vittoria
Ranch Hand

Joined: Jan 12, 2005
Posts: 33



Thank you so much Ernest!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need some with a program that won't compile.
 
Similar Threads
repainting JLabels on a JPanel
Making co-ordinates co-operate!
I'm sure I'm doing something very dumb.... why can't I see my JLabel?
how to set Box color?
Help needed with the Code