⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showimage_1.java

📁 主要是对于JAVA的编程的基本语言 希望能够帮得上你。
💻 JAVA
字号:
package applet;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;

/*
 * 演示双缓冲技术,防止图像抖动
 */

public class ShowImage_1 extends Applet implements Runnable{
	Image offImage;
	Graphics offGraphics;
	Image image;
	Thread thread;
	boolean m_bRunning;
	int iPosY;
	
	public void init(){
		image=this.getImage(this.getCodeBase(),"applet/bird.jpg");		
	}
	
	public void start(){
		m_bRunning=true;
		thread=new Thread(this);
		thread.start();
	}
	
	public void stop(){
		m_bRunning=false;
	}
	
	public void update(Graphics g){
		paint(g);
	}
	
	public void paint(Graphics g){	
		offImage = createImage(this.getWidth(), this.getHeight());		
		offGraphics = offImage.getGraphics();
		offGraphics.setColor( getBackground() );
		offGraphics.fillRect(0, 0, this.getWidth(), this.getHeight());		
		offGraphics.drawImage(image,0,0,this.getWidth(),this.getHeight(),this);	
		offGraphics.setColor(Color.RED);
		offGraphics.fillArc(80, iPosY, 50,50, 0, 360);
		
		g.drawImage(offImage,0,0,this);
		
	}

	public void run()  {
		while(m_bRunning){
			if(iPosY<this.getHeight()){
				iPosY++;
			}else{
				iPosY=-50;
			}
				
			repaint();
			try {
				Thread.sleep(50);
			} catch (InterruptedException e) {			
				e.printStackTrace();				
			}
		}		
	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -