Results 1 to 2 of 2
  1. #1
    barney is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default Error: myframe.java:26: ')' expected

    I do not see anything wrong with this code, but I keep getting an error when I try to compile. I use JDK environment and just compile in a command prompt window. The error I get is:

    Java Code:
    myframe.java:26: ')' expected
    if( (x+=3) 200) continue;
    1 error
    The code and the text in red is where the error is supposed to be. In the error message, the "<" doesn't show for some reason.
    Java Code:
    import java.awt.*;
    class myframe extends Frame {
    static int x=0,y=120; // x,y position to display message
    static int i=0;
    static int LtoR=1; // 1->msg L-to-R, 0->top to bot.
    Font fb = new Font("TimesRoman", Font.BOLD, 36);
    String msg[]={"Java", "Portable", "Secure", "Easy"};
    Color color[]={Color.blue, Color.yellow, Color.green, Color.red};
    
    public void paint(Graphics g) { // gets called by the runtime
    g.setFont( fb );
    g.setColor( color[i] );
    g.drawString(msg[i],x,y);
    }
    
    static public void main(String s[]) throws Exception {
    myframe mf = new myframe();
    mf.setSize(220,200);
    int pixelsPerLine=200, totalLines=4;
    mf.setVisible(true);
    
    for (int j=0;j<pixelsPerLine*totalLines; j++) {
    Thread.sleep(25);
    mf.repaint();
    if (LtoR==1) {
    [COLOR="Red"]if ( (x+=3) < 200) continue;[/COLOR]
    i = ++i % 4; // mv i to next msg/color
    x=50; y=0; LtoR=0; // mv msg top to bot next
    } else {
    if ( (y+=3) < 200) continue;
    i = ++i % 4; // mv i to next msg/color
    x=0; y=120; LtoR=1; // move msg L-to-R next
    }
    }
    
    System.exit(0);
    }
    }
    Thanks.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    I just copied, compiled and ran the code you posted. No compile errors and it ran okay.
    In the error message, the "<" doesn't show for some reason.
    Could it be that you are compiling a different file?

Similar Threads

  1. Identifier expected error
    By vasu18 in forum New To Java
    Replies: 1
    Last Post: 01-01-2008, 05:49 PM
  2. Error: ')' expected
    By baltimore in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:32 AM
  3. Error: '{' expected
    By romina in forum New To Java
    Replies: 1
    Last Post: 07-26-2007, 09:34 AM
  4. My error is: ')' expected
    By silvia in forum New To Java
    Replies: 1
    Last Post: 07-18-2007, 04:49 PM
  5. MSG ERROR: : expected
    By Marty in forum New To Java
    Replies: 1
    Last Post: 05-31-2007, 02:21 AM

Posting Permissions

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