Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: implements MouseListener doesn't work why

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default implements MouseListener doesn't work why

    The problem is in RED

    the code that is in red is not compiled ... why .. What I missed in my code

    package promouseevent;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
     
    public class ProMouseEvent1 extends JFrame
    {
       public ProMouseEvent1(String title)
       {
     
       }
     
       [COLOR="Red"]private class MouseWatcher implements MouseListener[/COLOR]
       {
     
       }
     
    }

    this is the output error:
    init:
    deps-jar:
    Compiling 1 source file to C:\NBGuide\ProMouseEvent\build\classes
    C:\NBGuide\ProMouseEvent\src\promouseevent\ProMouseEvent1.java:39: promouseevent.ProMouseEvent1.MouseWatcher is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
       private class MouseWatcher implements MouseListener
    1 error
    BUILD FAILED (total time: 0 seconds)
    Last edited by voltaire; May 1st, 2010 at 03:17 PM.


  2. #2
    Junior Member
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: implements MouseListener doesn't work why

    I solved it myself ..

    When to implement an abstract interface, I should provide the code for all the abstract methods to get my code to compile and work... if I don't want the method to does any action just write the method with empty braces.



    package promouseevent;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
     
    public class ProMouseEvent1 extends JFrame
    {
       public ProMouseEvent1(String title)
       {
     
       }
     
       private class MouseWatcher implements MouseListener
       {
          public void mouseClicked(MouseEvent e)
          {
     
          }
     
          public void mouseEntered(MouseEvent e)
          {
     
          }
     
          public void mouseReleased(MouseEvent e)
          {
     
          }
     
          public void mousePressed(MouseEvent e)
          {
     
          }
     
          public void mouseExited(MouseEvent e)
          {
     
          }
       }
     
    }
    Last edited by voltaire; May 1st, 2010 at 04:36 PM.

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: implements MouseListener doesn't work why

    Well done for solving your thread

    I have moved it to the Swing forum and marked it as solved!
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. [SOLVED] Can't get JFreeChart to work
    By igniteflow in forum Java SE APIs
    Replies: 2
    Last Post: February 15th, 2011, 02:19 AM
  2. MouseListener & MouseMotionListener
    By JavaLearner in forum AWT / Java Swing
    Replies: 9
    Last Post: March 26th, 2010, 07:18 AM
  3. mouse Released no work!!
    By frenkelor in forum AWT / Java Swing
    Replies: 1
    Last Post: January 23rd, 2010, 06:41 AM
  4. my run program does not work
    By rman27bn in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 16th, 2009, 09:13 AM
  5. Why won't this while loop work?
    By trueblue in forum Loops & Control Statements
    Replies: 2
    Last Post: July 17th, 2009, 09:10 AM