Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
book-of-vaadin.pdf
Скачиваний:
88
Добавлен:
24.03.2015
Размер:
13.43 Mб
Скачать

User Interface Components

// Display the image

Image image = new Image(null, imageResource);

When refreshing, you also need to call markAsDirty() for the Image object.

//This needs to be done, but is not sufficient image.markAsDirty();

//Generate a filename with a timestamp

SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");

String filename = "myfilename-" + df.format(new Date()) + ".png";

// Replace the filename in the resource imageResource.setFilename(makeImageFilename());

5.18.2. Adobe Flash Graphics

The Flash component allows embedding Adobe Flash animations in Vaadin UIs.

Flash flash = new Flash(null,

new ThemeResource("img/vaadin_spin.swf")); layout.addComponent(flash);

You can set Flash parameters with setParameter(), which takes a parameter's name and value as strings. You can also set the codeBase, archive, and standBy attributes for the Flash object element in HTML.

5.18.3. BrowserFrame

The BrowserFrame allows embedding web content inside an HTML <iframe> element. You can refer to an external URL with ExternalResource.

As the BrowserFrame has undefined size by default, it is critical that you define a meaningful size for it, either fixed or relative.

BrowserFrame browser = new BrowserFrame("Browser",

new ExternalResource("http://demo.vaadin.com/sampler/")); browser.setWidth("600px");

browser.setHeight("400px");

layout.addComponent(browser);

Notice that web pages can prevent embedding them in an <iframe>.

5.18.4. Generic Embedded Objects

The generic Embedded component allows embedding all sorts of objects, such as SVG graphics, Java applets, and PDF documents, in addition to the images, Flash graphics, and browser frames which you can embed with the specialized components.

For example, to display a Flash animation:

// A resource reference to some object

Resource res = new ThemeResource("img/vaadin_spin.swf");

// Display the object

Embedded object = new Embedded("My Object", res); layout.addComponent(object);

Or an SVG image:

Adobe Flash Graphics

161

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]