关于rcp在canvas中不断显示图片的问题,求大侠!

cws564752588 2013-02-07 05:51:07
public class TestShell extends Shell {

/**


* Launch the application.

* @param args

*/

Canvas canvas = new Canvas(this,SWT.NO_BACKGROUND);



public Canvas getCanvas() {

return canvas;

}



public void setCanvas(Canvas canvas) {


this.canvas = canvas;

}



public static void main(String args[]) {


try {

Display display = Display.getDefault();

final TestShell shell = new TestShell(display);

shell.getCanvas().addPaintListener(new PaintListener() {



@Override

public void paintControl(PaintEvent e) {

// TODO Auto-generated method stub

Image image=null;

for (int i = 0; i <3; i++) {

image=new Image(null, "d:\\"+(i+1)+".jpg");

shell.getCanvas().redraw();

e.gc.drawImage(image ,0, 0);

try {

Thread.sleep(2000);

shell.getCanvas().redraw();//每张图画完后停2秒,然后组件redraw()

} catch (InterruptedException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

}

}

});



shell.open();

shell.layout();

while (!shell.isDisposed()) {

if (!display.readAndDispatch()) {

display.sleep();

}

}

} catch (Exception e) {

e.printStackTrace();

}

}
我在运行的时候,每张图都被画在了canvas上。。。叠在一起了,我用redraw还是不行。。。希望有大侠帮小弟看下!

...全文
139 回复 点赞 打赏 收藏 举报
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
Eclipse
加入

5.8w+

社区成员

Java Eclipse
申请成为版主
帖子事件
创建了帖子
2013-02-07 05:51
社区公告
暂无公告