Results 1 to 4 of 4
  1. #1
    lost1000 is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default Bouncing Ball program

    First and foremost, thanks in advance.

    My program is suppose to have balls bouncing off the walls, changing colors each time they do so. I'm not sure what the issue is, however I am getting the following errors:


    Ball.java:2: package javax.awt.event does not exist
    import javax.awt.event.*;
    ^

    Ball.java:34: cannot find symbol
    symbol : class MouseEvent
    location: class Ball
    private void createBall(MouseEvent event)
    ^

    Ball.java:19: addMouseListener(java.awt.event.MouseListener) in java.awt.Component cannot be applied to ()
    addMouseListener();
    ^

    Ball.java:21: cannot find symbol
    symbol : class MouseAdapter
    location: class Ball
    new MouseAdapter()



    I can't figure out with the problem is, so any and all help is greatly appreciated.

    Again, thanks in advance.

    code

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default

    Lets take it from the top.
    package javax.awt.event does not exist
    That's right, it doesn't. What made you think it does?

    db
    Last edited by DarrylBurke; 11-18-2010 at 08:02 AM.

  3. #3
    lost1000 is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default

    Oh, I see what I did there. Thanks.

    Okay. I have that fixed and now have it down to one error:


    Ball.java:19: addMouseListener(java.awt.event.MouseListener) in java.awt.Component cannot be applied to ()
    addMouseListener();

    Not sure what that means.

    [updated]

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    1) You're calling addMouseListener but not passing a mouse listener as a parameter to the method.

    Specifically, you have this:
    Java Code:
    addMouseListener();

    When you need this:
    Java Code:
    addMouseListener( /* MouseListener object goes here! */ );


    2) You're likely to get more help if you post your code right here in the forum rather than use a link, but please don't forget to use code tags (see my first signature link).
    3) Consider changing your style of programming as you seem to be creating a bunch of code, compiling it, then trying to wade through a lot of errors. Better would be to start small, add a small amount of code at a time, compile frequently, and most importantly, not add any new code to the project until the current code compiles and runs correctly. Otherwise you'll end up with nothing more than a rat's nest of unfixable errors.

    Luck!
    Last edited by Fubarable; 11-18-2010 at 05:27 PM.

Similar Threads

  1. Bouncing ball program... having problems..
    By ilovenayoon in forum Java Applets
    Replies: 1
    Last Post: 12-08-2009, 05:16 PM
  2. How to create a bouncing ball animation
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-21-2008, 09:43 PM
  3. high bouncing ball
    By bouncingball in forum Reviews / Advertising
    Replies: 1
    Last Post: 06-19-2008, 12:21 PM
  4. bouncing ball issue
    By adam405 in forum New To Java
    Replies: 1
    Last Post: 03-18-2008, 04:48 AM
  5. Problem deleting ball from bouncing ball app
    By adlb1300 in forum New To Java
    Replies: 2
    Last Post: 12-03-2007, 10:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •