Shi*_*iri 3 java vaadin vaadin7
我正在将文件中的图像插入到UI中.我按照这些说明在Vaadin 7.6.8中创建它.
String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
FileResource resource = new FileResource(new File(basepath + "/WEB-INF/images/image.png"));
Image image = new Image("", resource);
Run Code Online (Sandbox Code Playgroud)
但是我根本无法重新缩放图像或调整图像大小.图像始终以完整大小显示.
有没有一种方法可以缩小图像而不使用CSS?
您可以指定图像组件的高度和宽度,
FileResource resource = new FileResource(new File("D:/image.jpg"));
Image image = new Image("", resource);
image.setWidth(200, Unit.PIXELS);
image.setHeight(200, Unit.PIXELS);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3220 次 |
最近记录: |