Results 1 to 5 of 5
  1. #1
    ebrown086 is offline Member
    Join Date
    Aug 2013
    Posts
    6
    Rep Power
    0

    Default Syntax error on token "(", @ expected and more errors

    Hello. I have been having errors in my script. I am trying to create a JFrame Pixel-Engine, yet I keep encountering the same error, no matter what I do. I believe that I have imported all the correct files, and I cannot find anything that is actually wrong with my script...any help would be nice.

    Here is the code:
    Java Code:
    import java.awt.Canvas;
    import java.awt.Dimension;
    import java.awt.image.BufferedImage;
    
    // If there is a problem with importing, it is more than likely this 
    // one, because it is the one that Eclipse nor JCreator autoimport as 
    // I am programming.
    import java.awt.image.DataBufferInt;
    import java.util.Random;
    import javax.swing.JFrame;
    
    public class Game extends Canvas implements Runnable {
    	
      private static final long serialVersionUID = 1L;
      public static final int HEIGHT = 120;
      public static final int WIDTH = 120; 
      public static final int SCALE = 3; 
      public static final String NAME = "Pixel_Engine";
      private BufferedImage image = new BufferedImage(WIDTH, HEIGHT,
          BufferedImage.TYPE_INT_BGR);
    
      // error appears on this line Multiple markers at this line-
      // Syntax error on token "(", @ expected- Syntax error on token ".",
      // { expected- Watchpoint:Game [access and modification] - pixels- Syntax error on token(s),
      // misplaced construct(s)- Syntax error on token ")", delete this token*/	
      private int[] pixels ((DataBufferInt() image.getRaster().getDataBuffer()).getData();
    
      // and on this line Multiple markers at this line-
      // Syntax error, insert "}" to complete MethodBody	
      Random random = new Random();
    
      public void run(){
      }
    
      public static void main(String[] args){
        Game game = new Game();
    		
        game.setPreferredSize(new Dimension(WIDTH * SCALE,HEIGHT * SCALE));
        game.setMaximumSize(new Dimension(WIDTH * SCALE,HEIGHT * SCALE));
        game.setMinimumSize(new Dimension(WIDTH * SCALE,HEIGHT * SCALE));
    		
        JFrame frame = new JFrame(NAME);
        frame.add(game);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
        frame.setResizable(true);
      }
    }
    Last edited by DarrylBurke; 08-17-2013 at 06:28 PM. Reason: Improved code formatting, edited subject line

  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 Re: Needing Help With an Error

    Please go through the Forum Rules, particularly the third paragraph. Then go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

    And don't try using color tags inside of code tags. Highlight lines with inline comments.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    ebrown086 is offline Member
    Join Date
    Aug 2013
    Posts
    6
    Rep Power
    0

    Default Re: Needing Help With an Error

    Thank you. How do I change the thread name? I have edited the post as suggested, but cannot find a way to change the thread? should I start a new one with a better thread name?

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

    Default Re: Needing Help With an Error

    Quote Originally Posted by ebrown086 View Post
    How do I change the thread name?
    Edit Post -> Go Advanced

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

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

    Default Re: Syntax error on token "(", @ expected and more errors

    OK I've done that for you and also improved the code formatting so it can be read. For forum postings, avoid using tabs for indents; 2 to 4 spaces are recommended. Line length should be kept within 80 characters. And this forum software has a bug with /* ... */ block comments, so use either // inline comments or /** ...*/ doc comments.

    What exactly are you trying to achieve at line 26? That isn't valid Java code, and that's why the compiler is complaining.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Needing help with strings
    By RUReady18 in forum New To Java
    Replies: 8
    Last Post: 02-11-2013, 09:42 PM
  2. A newbie to Java needing help on coding error
    By Turo in forum New To Java
    Replies: 5
    Last Post: 08-28-2011, 06:11 AM
  3. Java installation error needing soLution!!!
    By ese in forum New To Java
    Replies: 26
    Last Post: 07-31-2011, 08:29 PM
  4. Needing help with GroupLayout
    By Janohjk in forum AWT / Swing
    Replies: 2
    Last Post: 06-18-2011, 11:41 AM
  5. Needing Help!!
    By kingjut06 in forum JDBC
    Replies: 1
    Last Post: 07-08-2007, 12:38 AM

Tags for this Thread

Posting Permissions

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