zoukankan      html  css  js  c++  java
  • java初学。加载图片

    public class GameFrame extends Frame{
      private static final int WIDTH=900;
      private static final int HEIGHT=600;
      Man man=new Man();

      public void paint(Graphics g){
        man.draw(g);
      }
      public void loadFrame(){
        this.setSize(WIDTH, HEIGHT);
        this.setLocation(50,50);
        this.setTitle("工作室--洪七公打狗");
        this.setVisible(true);
        new PaintThread().start();
      }
      public static void main(String[] args) {
        new GameFrame().loadFrame();
      }

      class PaintThread extends Thread{
        @Override
        public void run() {
          // TODO Auto-generated method stub
          while(true){
            repaint();
            try {
              Thread.sleep(40);
            } catch (Exception e) {
              // TODO: handle exception

            }
          }
        }
      }
    }

    //Man类

    public class Man {

      //加载图片
      private Image img=Toolkit.getDefaultToolkit().getImage("Images/people.jpg");
      public void draw(Graphics g){
        g.drawImage(img, 50, 400, null);
      }
    }

  • 相关阅读:
    微博深度学习平台架构和实践
    2020暑期学习
    2020春季学期个人课程总结
    人月神话阅读笔记03
    人月深化阅读笔记02
    第十六周学习总结
    人月神话阅读笔记01
    三分算法
    [SDOI2010]魔法猪学院
    【洛谷】NOIP2018原创模拟赛DAY1解题报告
  • 原文地址:https://www.cnblogs.com/wangxiangstudy/p/4540579.html
Copyright © 2011-2022 走看看