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 7 of 7

Thread: Help With illegal start of expression

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help With illegal start of expression

    hi all.. plz help me
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class Mouse implements MouseMotionListener{
    JFrame f;
    JLabel coord;
    public void initGUI(){
    JFrame f=new JFrame();
    JLabel coord=new JLabel();
    Container con=f.getContentPane();
    con.add(coord);
    f.setLayout(new FlowLayout());
    f.setSize(400,400);
    f.setVisible(true);
    f.addMouseMotionListener(this);
    public void mouseDragged(MouseEvent me){int x=me.getX();
    				int y=me.getY();
    				coord.setText("Dragged at [" + x + "," + y + "]" );         }
    public void mouseMoved(MouseEvent me){
     				         int x = me.getX();
             int y = me.getY();
     
             coord.setText("Moved at [" + x + "," + y + "]" );
     }
    }
    public void Mouse(){
    			initGUI();
    	}
    public static void main(String args[]){
    		Mouse ex=new Mouse();
    			}
    }
    Last edited by Norm; February 9th, 2013 at 11:13 AM. Reason: changed quote to code tags


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help With illegal start of expression

    Moved to own thread.

    Please explain your problem.


    Also please edit the code and format it properly.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Help With illegal start of expression

    inshal: please don't hijack someone else's question. I have moved your question to its own thread, and Norm has added code tags so that the code retains its formatting. You will want to give us the details on what's wrong with your code including posting any and all error messages and any questions that you might have.

  4. #4
    Junior Member
    Join Date
    Feb 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need help with illegal start of expression

    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class Mouse implements MouseMotionListener{
    JFrame f;
    JLabel coord;
    public void initGUI(){
    JFrame f=new JFrame();
    JLabel coord=new JLabel();
    Container con=f.getContentPane();
    con.add(coord);
    f.setLayout(new FlowLayout());
    f.setSize(400,400);
    f.setVisible(true);
    f.addMouseMotionListener(this);
    public void mouseDragged(MouseEvent me){int x=me.getX();
    				int y=me.getY();
    				coord.setText("Dragged at [" + x + "," + y + "]" );         }
    public void mouseMoved(MouseEvent me){
     				         int x = me.getX();
             int y = me.getY();
     
             coord.setText("Moved at [" + x + "," + y + "]" );
     }
    }
    public void Mouse(){
    			initGUI();
    	}
    public static void main(String args[]){
    		Mouse ex=new Mouse();
    			}
    }

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help With illegal start of expression

    Merged with other thread.

    Please explain your problem. Copy and paste full text of error messages


    Also please edit the code and format it properly.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Feb 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help With illegal start of expression

    illelgal start of expression at line 16 and 20... sorry but i am doing it with cmd window.. dont know how to copy that text...
    plz help...

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help With illegal start of expression

    Check that all the {s have a matching }
    and that all method definitions end (the ending }) before another method's definition starts.

    On windows: To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Help With illegal start of expression
    By RaceRed in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 7th, 2013, 09:02 PM
  2. Need HELP! Illegal start of expression & while expected..
    By Zaki in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 15th, 2012, 04:22 PM
  3. PROBLEM: ILLEGAL START OF EXPRESSION
    By zerfgog in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 29th, 2012, 06:24 AM
  4. illegal start of expression error!!!!
    By aks.1393 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 14th, 2011, 08:47 AM