?? imagedemo.java
字號:
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
public class ImageDemo {
public static Display myDisplay;
public static boolean internalCall = false;
public static void main(String[] args) {
internalCall = true;
myDisplay = new Display();
ImageDemo id = new ImageDemo();
id.runDemo(myDisplay);
}
public void runDemo(Display display) {
myDisplay = display;
Shell shell = new Shell(display);
shell.setSize(140,100);
shell.setText("Image Demo");
//load an image from a JPEG file
Image img = new Image(display, "EclipseBannerPic.jpg");
// //roughly equivalent code that works for loading an image from a JAR file
// InputStream is = getClass().getResourceAsStream("EclipseBannerPic.jpg");
// Image img = new Image(display, is);
//open the shell, so we can draw on it
shell.open();
//get a Graphics Context
GC gc = new GC(shell);
//draw the image at a specific x and y location
gc.drawImage(img, 0, 0);
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
//dispose of the image object
img.dispose();
if (internalCall) display.dispose();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -