源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

java使用swt显示图片示例分享

  • 时间:2020-09-10 01:53 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:java使用swt显示图片示例分享
[u]复制代码[/u] 代码如下:
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class ImagesHelloWorld {  public static void main(String[] args) {   Display display = Display.getDefault();   Shell shell = new Shell();   Image image = new Image(display, "c://c240b2dcc132c9c6.jpg");   shell.setText("ImageReader");   shell.setImage(image);   Rectangle bounds = image.getBounds();   shell.setSize(bounds.width + 15, bounds.height +15);   shell.open();   GC gc = new GC(shell);   gc.drawImage(image,5,5);   shell.layout();   while (!shell.isDisposed()) {    if (!display.readAndDispatch()) {     display.sleep();    }   }   display.dispose();  } }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部