package com.plane;

import java.awt.Graphics;
import java.awt.Image; import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel; public class PlaneMain extends JPanel{
private Image background;
private Plane pl;
public static void main(String[] args) {
new PlaneMain();
}
public PlaneMain(){ background = new ImageIcon(this.getClass().getResource("background.jpg")).getImage();
pl = new Plane(background,0,-100,this);
initUI(); } public void initUI(){
JFrame jf = new JFrame();
jf.setSize(1000, 900);
jf.setDefaultCloseOperation(3);
jf.setLocationRelativeTo(null); jf.add(this);
jf.setVisible(true);
pl.start(); }
//Plane pl = new Plane(background,0,0,this);
public void paint(Graphics g){
super.paint(g);
g.drawImage(pl.background, pl.x, pl.y, 1000, 1000, this); }
}
package com.plane;

import java.awt.Image;

import javax.swing.JPanel;

public class Plane extends Thread{
public Image background;
public int x=0;
public int y=-60;
public JPanel jp;
public int movesp=2;
public Plane(Image background,int x,int y,JPanel jp){
this.background = background;
System.out.println(this.background);
this.x = x;
this.y = y;
this.jp = jp;
}
public void move(){
y+=movesp;
if (y==0){
y=-100;
}
}
public void run(){ while(true){
move();
jp.repaint();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

最新文章

  1. Android图片资源
  2. $(this)与this的区别
  3. php调用一个c语言写的接口问题
  4. ThinkPHP中initialize和construct的不同
  5. bzoj 1791: [Ioi2008]Island 岛屿
  6. VSTO Word2003 添加菜单栏, 添加工具栏
  7. 使用VNC远程连接Windows Azure Linux虚拟机
  8. WCF-IIS-PDA
  9. AssetManager中的路径参数不能包含"assets/"
  10. 在JS事件封装时,addEventListener()方法的this问题
  11. eclipes快捷键
  12. 洛谷 P4168 [Violet] 蒲公英
  13. angular2报错
  14. js中 switch 注意事项
  15. 【SqlServer】SqlServer的游标使用
  16. opencv -python
  17. Java happen-before
  18. 快速了解和使用Photon Server
  19. 操作系统:Android(Google公司开发的操作系统)
  20. php利用root权限执行shell脚本 (转)

热门文章

  1. ceilometer alarm 创建过程中的DB操作及优化
  2. JavaScript 对时间日期格式化
  3. PyCharm 的初始设置2 - 打开、新建项目
  4. 《Advanced Bash-scripting Guide》学习(十九):两个整数的最大公约数
  5. Get UTI (uniform type identifier) and ContentType
  6. Spring3.2.9 + JdbcTemplate 学习
  7. 制作导航菜单分隔线的总结:用css3
  8. 17 python 内置函数
  9. stencil in unity3d
  10. kibana 统计field所有值百分比