调整 Vaadin 图像的大小 [英] Resizing Vaadin Image

查看:23
本文介绍了调整 Vaadin 图像的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将文件中的图像插入 UI.我按照 这些 说明.

I am inserting an image from file into a UI. I am creating it in Vaadin 7.6.8 by following these instructions.

String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
FileResource resource = new FileResource(new File(basepath + "/WEB-INF/images/image.png"));
Image image = new Image("", resource);

但是我根本无法重新缩放或调整图像大小.图像始终以全尺寸显示.

However I am unable to rescale or resize the image at all. The image is always being displayed in full size.

有没有一种方法可以不使用 CSS 缩小图像?

Is there a way that I can scale down the image without using CSS ?

推荐答案

您可以指定图像组件的高度宽度

You can specify height and width of the image component,

FileResource resource = new FileResource(new File("D:/image.jpg"));
Image image = new Image("", resource);
image.setWidth(200, Unit.PIXELS);
image.setHeight(200, Unit.PIXELS);

这篇关于调整 Vaadin 图像的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆