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

📄 offscreenimagedemo.java

📁 java图形界面开发
💻 JAVA
字号:
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class OffscreenImageDemo {

	public static Display myDisplay;
	public static boolean internalCall = false;

	public static void main(String[] args) {
		internalCall = true;
		myDisplay = new Display();
		OffscreenImageDemo id = new OffscreenImageDemo();
		id.runDemo(myDisplay);
	}
	
	public void runDemo(Display display) {
		myDisplay = display;
		Shell shell = new Shell(display);
		shell.setSize(100,100);
		shell.setText("OffScreen Image Demo");

		//load an image from a JPEG file
		Image img = new Image(display, 50,50);		

		//open the shell, so we can draw on it
		shell.open();

		//create a graphics context for the offscreen image
		GC imgGC = new GC(img);
			
		//draw a line onto the image in memory
		imgGC.drawLine(10, 20, 30, 40);
		
		//get a Graphics Context
		GC shellGC = new GC(shell);
		
		//draw the image to the screen
		shellGC.drawImage(img, 0, 0);

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		
		img.dispose();
		if (internalCall) display.dispose();

	}
	
}

⌨️ 快捷键说明

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