java吧 关注:1,254,622贴子:12,741,883
  • 9回复贴,共1

大过年的,求大神帮帮我

只看楼主收藏回复

帮我改改代码,运行出来没图片啊,图片路径对的


1楼2015-02-19 12:05回复
    package FirstSteps;
    import java.awt.Graphics;
    import java.awt.Color;
    import java.awt.Image;
    import java.awt.Container;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.ImageIcon;
    public class FootTest extends JPanel
    {
    private Image shoe;
    // Constructor
    public FootTest()
    {
    shoe = (new ImageIcon("leftshoe.gif")).getImage();
    }
    // Called automatically when the panel needs repainting
    public void paintComponent(Graphics g)
    {
    super.paintComponent(g);
    int x = 300;
    int y = 100;
    int stepLength = 100;
    Foot foot = new Foot(x, y, shoe);
    for (int count = 1; count <= 8; count++)
    {
    foot.draw(g);
    foot.turn(45);
    foot.moveForward(stepLength);
    }
    // Draw a cursor at the expected center of the first "shoe":
    g.drawLine(x - 50, y, x + 50, y);
    g.drawLine(x, y - 50, x, y + 50);
    }
    public static void main(String[] args)
    {
    JFrame window = new JFrame("Feet");
    window.setBounds(100, 100, 500, 480);
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    FootTest panel = new FootTest();
    panel.setBackground(Color.WHITE);
    Container c = window.getContentPane();
    c.add(panel);
    window.setVisible(true);
    }
    }


    2楼2015-02-19 12:06
    回复
      有人吗


      3楼2015-02-19 12:16
      回复


        4楼2015-02-19 12:18
        回复


          5楼2015-02-19 13:10
          回复
            都没人鸟我


            来自iPhone客户端6楼2015-02-19 14:20
            回复
              graphics那部分有点问题,要把foot弄出来


              来自iPhone客户端7楼2015-02-19 14:21
              回复


                来自iPhone客户端8楼2015-02-19 20:54
                回复


                  来自iPhone客户端9楼2015-02-19 20:54
                  回复


                    来自iPhone客户端10楼2015-02-19 20:55
                    回复