3

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.

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

akash
  • 22,664
  • 11
  • 59
  • 87
Shiri
  • 1,972
  • 7
  • 24
  • 46

1 Answers1

7

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);
akash
  • 22,664
  • 11
  • 59
  • 87