7
我想畫一個SWT圖像,但似乎沒有什麼:如何繪製swt圖像?
Display display = new Display();
Shell shell = new Shell(display);
shell.open();
Image image = new Image(display, "C:/sample_image.png");
Rectangle bounds = image.getBounds();
GC gc = new GC(image);
gc.drawImage(image, 100, 100);
// gc.drawLine(0, 0, bounds.width, bounds.height);
// gc.drawLine(0, bounds.height, bounds.width, 0);
// gc.dispose();
// image.dispose();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
我已經測試過的圖像存在,並且有內容 - 任何想法?
你想在哪兒畫這幅圖像? – 2011-05-31 12:54:00
在我的顯示器上。外殼打開但空了。 – u123 2011-05-31 12:56:51
可能的重複[如何顯示與swt在Java中的圖像?](http://stackoverflow.com/questions/4447455/how-to-show-up-an-image-with-swt-in-java) – McDowell 2011-05-31 13:21:55