View Single Post
Old Nov 6th, 2006, 10:14 AM   #11
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,649
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
First off there is no need for the sarcasm and rudeness against the new member.

@kenny1591: Please read through the rules here at Programming forums
http://www.programmingforums.org/for...q=faq_policies

If you look up at your code you posted (I have added the [highlight] tag to your code to preserve the formatting. If you look at it your closing brackets are not in the right places. You are not closing paintComponent. You have enough } but you have 2 of them at the very bottom and you need another one before main. If you look at the code you should see that. You will also need to remove one of the extra ones. Something like this.

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. } // <= Look here and again at the very bottom
  41.  
  42. public static void main(String[] args)
  43. {
  44. JFrame window = new JFrame("Walker");
  45. window.setBounds(100, 100, 500, 480);
  46. window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  47.  
  48. WalkerTest panel = new WalkerTest();
  49. panel.setBackground(Color.WHITE);
  50. Container c = window.getContentPane();
  51. c.add(panel);
  52.  
  53. window.setVisible(true);
  54. }
  55. }
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote