19 package org.turro.file.zul.tree;
21 import java.awt.image.BufferedImage;
23 import javax.imageio.ImageIO;
24 import org.turro.preview.Preview;
25 import org.zkoss.zk.ui.event.EventListener;
26 import org.zkoss.zk.ui.event.Events;
27 import org.zkoss.zk.ui.event.OpenEvent;
28 import org.zkoss.zul.Image;
29 import org.zkoss.zul.Popup;
35 public class FilePreview extends Popup implements EventListener<OpenEvent> {
41 addEventListener(Events.ON_OPEN,
this);
45 public void onEvent(OpenEvent event)
throws Exception {
46 getChildren().clear();
47 Preview preview = Preview.from(file);
48 File result = preview.get();
50 BufferedImage bi = ImageIO.read(result);
51 setHeight((bi.getHeight() + 12) +
"px");
52 setWidth((bi.getWidth() + 12) +
"px");
53 Image image =
new Image();
void onEvent(OpenEvent event)