View Single Post
Old Nov 5th, 2006, 9:19 PM   #7
kenny1591
Newbie
 
Join Date: Nov 2006
Posts: 4
Rep Power: 0 kenny1591 is an unknown quantity at this point
how do i fix an illegal start of expression error on this program


java Syntax (Toggle Plain Text)
  1. import java.awt.Graphics;
  2. import java.awt.Color;
  3. import java.awt.Image;
  4. import java.awt.Container;
  5. import javax.swing.JFrame;
  6. import javax.swing.JPanel;
  7. import javax.swing.ImageIcon;
  8.  
  9. public class WalkerTest extends JPanel
  10. {
  11. private Image leftShoe;
  12. private Image rightShoe;
  13.  
  14. // Constructor
  15. public WalkerTest()
  16. {
  17. leftShoe = (new ImageIcon("leftShoe.gif")).getImage();
  18. rightShoe = (new ImageIcon("rightShoe.gif")).getImage();
  19. }
  20.  
  21. // Called automatically when the panel needs repainting
  22. public void paintComponent(Graphics g)
  23. {
  24. super.paintComponent(g);
  25.  
  26. int x = 300;
  27. int y = 100;
  28. int stepLength = 100;
  29.  
  30. Walker walker = new Walker(x, y, leftShoe, rightShoe);
  31. for (int count = 1; count <= 8; count++)
  32. {
  33. walker.draw(g);
  34. walker.nextStep();
  35.  
  36. // Draw a cursor at the expected center of the first "shoe"
  37. g.drawLine(x - 50, y, x + 50, y);
  38. g.drawLine(x, y - 50, x, y + 50);
  39. }
  40.  
  41. public static void main(String[] args)
  42. {
  43. JFrame window = new JFrame("Walker");
  44. window.setBounds(100, 100, 500, 480);
  45. window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  46.  
  47. WalkerTest panel = new WalkerTest();
  48. panel.setBackground(Color.WHITE);
  49. Container c = window.getContentPane();
  50. c.add(panel);
  51.  
  52. window.setVisible(true);
  53. }
  54. }
  55. }





On the line that says:
public static void main(String[] args)




Please help.:banana: :banana: :banana: :banana: :banana: :banana:

Last edited by big_k105; Nov 6th, 2006 at 11:10 AM. Reason: added code tags
kenny1591 is offline   Reply With Quote