Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2003
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Java error code 26?

    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:

    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.

    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) {
    if ( (x+=3) < 200) continue;
    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
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kentucky
    Posts
    133
    Thanks
    0
    Thanked 1 Time in 1 Post
    I copied your code and compiled it with no problem at all (using command window, like you). I'd say you're editing one file, and compiling another. Double-check that.


  •  

    Posting Permissions

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