Results 1 to 2 of 2
  1. #1
    lalitha is offline Member
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Question error: '{"expected in 10 line

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;

    /*
    <applet code="MouseEventProgram" width=300 height=100>
    </applet>
    */

    public class MouseEventProgram extend Applet implements MouseListener, MouseMotionListener
    {

    String msg = " ";
    int mouseX=0, mouseY=0; //coordiantes of mouse

    public void init()
    {
    addMouseListener(this);
    addMouseMotionListener(this);
    }

    //handle MouseListener and MouseMotionListener methods

    public void mouseClicked(MouseEvent me)
    {
    mouseX=0; //save coordiantes
    mouseY=10;
    msg = " mouse clicked";
    repaint();
    }

    public void mouseEntered(MouseEvent me)
    {
    mouseX=0; //save coordiantes
    mouseY=10;
    msg = " mouse entered";
    repaint();
    }

    public void mouseExited(MouseEvent me)
    {
    mouseX=0; //save coordiantes
    mouseY=10;
    msg = " mouse exited";
    repaint();
    }
    public void mousePressed(MouseEvent me)
    {
    mouseX=me.getX();
    mouseY=me.getY();
    msg = "down";
    repaint();
    }
    public void mouseReleased(MouseEvent me)
    {
    mouseX=me.getX();
    mouseY=me.getY();
    msg = "up";
    repaint();
    }
    public void mouseDragged(MouseEvent me)
    {
    mouseX=me.getX();
    mouseY=me.getY();
    msg = "*";
    showStatus("dragging mouse at "+mouseX+", "+mouseY);
    repaint();
    }
    public void mouseMoved(MouseEvent me)
    {
    mouseX=me.getX();
    mouseY=me.getY();
    msg = "****";
    showStatus("moving mouse at "+mouseX+", "+mouseY);
    repaint();
    }

    public void paint(Graphics g)
    {
    g.drawString(msg, mouseX,mouseY);
    }

    }


    please help me clear the error

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,965
    Rep Power
    8

    Default Re: error: '{"expected in 10 line

    When posting code, please use the code tags, otherwise your code is pretty hard to read.

    Take a look at the line in question. Are you sure you spelled everything correctly and used all the right syntax? Hint: You didn't.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Syntax error on token "}", super expected
    By amentjacob1 in forum New To Java
    Replies: 9
    Last Post: 07-06-2012, 04:15 AM
  2. Java "Identifier Expected" Error
    By Misho554 in forum New To Java
    Replies: 3
    Last Post: 03-15-2012, 05:09 PM
  3. Syntax error on token "(", ; expected
    By baltimore in forum AWT / Swing
    Replies: 3
    Last Post: 10-28-2009, 12:19 AM
  4. Syntax error on token "(", ; expected
    By romilc in forum New To Java
    Replies: 7
    Last Post: 10-24-2009, 01:23 AM
  5. Replies: 3
    Last Post: 12-05-2008, 08:34 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
  •